diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2017-11-19 22:51:57 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2017-11-23 08:56:38 +0100 |
commit | 691d6b33ee7454f9559239b86387bb5673274bec (patch) | |
tree | 419631c296cc4a5dba2e385611fb40713e285e7f /src/ui-calendar.c | |
parent | 97c3e7f95726533897c3e65a09ffd2cd02d7e187 (diff) | |
download | calcurse-691d6b33ee7454f9559239b86387bb5673274bec.tar.gz calcurse-691d6b33ee7454f9559239b86387bb5673274bec.zip |
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>
Diffstat (limited to 'src/ui-calendar.c')
-rw-r--r-- | src/ui-calendar.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ui-calendar.c b/src/ui-calendar.c index 93115da..07d82f3 100644 --- a/src/ui-calendar.c +++ b/src/ui-calendar.c @@ -713,18 +713,30 @@ void ui_calendar_move(enum move move, int count) ret = 1; /* NOTREACHED */ } - - if (ret == 0) { + if (ret == 1 || (YEAR1902_2037 && t.tm_year < 2) + || (YEAR1902_2037 && t.tm_year > 137)) { + char *out, *msg = _("The move failed (%d/%d/%d, ret=%d)."), ch; + asprintf(&out, msg, t.tm_mday, t.tm_mon + 1, t.tm_year + 1900, ret); + do { + status_mesg(out, _("Press [ENTER] to continue")); + ch = keys_wgetch(win[KEY].p); + } while (ch != '\n'); + mem_free(out); + wins_update(FLAG_STA); if (t.tm_year < 2) { t.tm_mday = 1; t.tm_mon = 0; t.tm_year = 2; } - - slctd_day.dd = t.tm_mday; - slctd_day.mm = t.tm_mon + 1; - slctd_day.yyyy = t.tm_year + 1900; + if (t.tm_year > 137) { + t.tm_mday = 31; + t.tm_mon = 11; + t.tm_year = 137; + } } + slctd_day.dd = t.tm_mday; + slctd_day.mm = t.tm_mon + 1; + slctd_day.yyyy = t.tm_year + 1900; } /* Returns the beginning of current year as a long. */ |