diff options
-rw-r--r-- | date.c | 2 | ||||
-rwxr-xr-x | t/t0006-date.sh | 5 |
2 files changed, 7 insertions, 0 deletions
@@ -74,6 +74,8 @@ static int local_tzoffset(unsigned long time) localtime_r(&t, &tm); t_local = tm_to_time_t(&tm); + if (t_local == -1) + return 0; /* error; just use +0000 */ if (t_local < t) { eastwest = -1; offset = t - t_local; diff --git a/t/t0006-date.sh b/t/t0006-date.sh index 57033ddcd1..04ce53509c 100755 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@ -48,6 +48,11 @@ check_show default "$TIME" 'Wed Jun 15 16:13:20 2016 +0200' check_show raw "$TIME" '1466000000 +0200' check_show iso-local "$TIME" '2016-06-15 14:13:20 +0000' +# arbitrary time absurdly far in the future +FUTURE="5758122296 -0400" +check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" +check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" + check_parse() { echo "$1 -> $2" >expect test_expect_${4:-success} "parse date ($1${3:+ TZ=$3})" " |