diff options
Diffstat (limited to '')
| -rw-r--r-- | source/parsing.c | 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-atom.c | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-shared.c | 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 files changed, 23 insertions, 5 deletions
diff --git a/source/parsing.c b/source/parsing.c index dab81fa..71ecdb7 100644 --- a/source/parsing.c +++ b/source/parsing.c @@ -71,10 +71,24 @@ static void parse_user(const char *line, char **name, char **email, timestamp_t strbuf_addch(&address, '>'); *email = strbuf_detach(&address, NULL); + // Clamped as git's own show_ident_date clamps them: a date past + // what the system can hold becomes the epoch, and a zone that is + // no hhmm offset becomes UTC, where git's date code would die on + // either and take the whole page with it. if (ident.date_begin) *date = parse_timestamp(ident.date_begin, NULL, 10); - if (ident.tz_begin) - *tz = atoi(ident.tz_begin); + if (date_overflows(*date)) + *date = 0; + if (ident.tz_begin) { + long zone = strtol(ident.tz_begin, NULL, 10); + long west = zone < 0 ? -zone : 0; + + *tz = zone > -10000 && zone < 10000 ? zone : 0; + // A date earlier than its own westward offset has no + // local time before the epoch to show. + if (*date < (timestamp_t)((west / 100) * 60 + west % 100) * 60) + *tz = 0; + } } } diff --git a/source/ui-atom.c b/source/ui-atom.c index 0f82c0d..55b59a1 100644 --- a/source/ui-atom.c +++ b/source/ui-atom.c @@ -24,6 +24,10 @@ */ static const char *feed_date(timestamp_t when) { + // The newest commit's date comes straight from git, unclamped, and + // git's date code dies on one the system cannot hold. + if (date_overflows(when)) + when = 0; return show_date(when, 0, date_mode_from_type(DATE_ISO8601_STRICT)); } diff --git a/source/ui-shared.c b/source/ui-shared.c index a0a0664..d1b9994 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1418,9 +1418,9 @@ void cgit_print_age(time_t t, int tz, time_t max_relative) if (!t) return; time(&now); - secs = now - t; - if (secs < 0) - secs = 0; + // A date past now, or one so far off that the difference cannot be + // held, reads as no age at all. + secs = t > now ? 0 : now - t; if (!ctx.cfg.enable_relative_dates || (secs > max_relative && max_relative >= 0)) { print_abs_date(t, tz); |
