Check for the year span 1902-2037

Reintroduce year check for systems with a 32-bit time_t type. Remove the
lower limit (1902) for systems with a 64-bit time_t. This limits
movements in the calendar (for 32-bit systems) and in no way ensures
constistency of data.

Commit a12833e (Handle dates past January 19th, 2038, 2015-01-19)
removed the upper limit (2037) on dates but left the lower limit (1902).
It did not ensure the support of the target system.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen
2017-11-19 22:51:57 +01:00
committed by Lukas Fleischer
parent 97c3e7f957
commit 691d6b33ee
3 changed files with 34 additions and 15 deletions

View File

@@ -304,10 +304,15 @@ enum datefmt {
/* Day heading default format. */
#define DAY_HEADING_DEFAULT "%B %-d, %Y"
/*
* Calcurse representation of the date of a day in the calendar.
* When time_t is a 32-bit signed integer, the year range is 1902 - 2037.
*/
#define YEAR1902_2037 (sizeof(time_t) == 4)
struct date {
unsigned dd;
unsigned mm;
unsigned yyyy;
unsigned dd; /* day: 1 - 31 */
unsigned mm; /* month: 1 - 12 */
unsigned yyyy; /* year AD */
};
#define ISLEAP(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)