Skip to content

Range of year is very restrictive #289

Description

@pjdupreez

Maybe I am missing something, or the reason behind it, probably because of Y2K of some such reason, so please enlighten me, or add a clear note to the documentation.

The range of the year is (2000 -- 2099). This seems a bit restrictive, especially when trying to do get the difference between 2 dates in 2 different centuries.

For example:
`
DateTime now = DateTime (2023, 7, 19);
DateTime then = DateTime (1980, 5, 25);

Serial.print("Now: ");
Serial.print(now.year(), DEC);
Serial.print('-');
Serial.print(now.month(), DEC);
Serial.print('-');
Serial.println(now.day(), DEC);

Serial.print("Then: ");
Serial.print(then.year(), DEC);
Serial.print('-');
Serial.print(then.month(), DEC);
Serial.print('-');
Serial.println(then.day(), DEC);

// Serial Output
// Now: 2023-7-19 <-- correct
// Then: 2188-5-25 <-- problem
`

Like I said, I probably missed the reason for this decision, if it is documented, so would like to know if there is a way around this limitation. Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions