]> Savannah Git Hosting - gnulib.git/commit
parse-datetime: add debug warning about DST changes
authorAssaf Gordon <assafgordon@gmail.com>
Thu, 5 Jan 2017 04:14:37 +0000 (23:14 -0500)
committerAssaf Gordon <assafgordon@gmail.com>
Thu, 5 Jan 2017 05:08:06 +0000 (00:08 -0500)
commit30a55dd72dad2fd3a92f62dbfef4afd7ec72e540
tree732729bf3325dc6f30fe836e91eeee75a2a0b6cf
parentf14eff1b3cde2bf8198b836ab4da05b4098358cb
parse-datetime: add debug warning about DST changes

Incorrect date arithmetic due to daylight saving time (DST) are a
common (false) bug report in coreutils.
Detect two such cases and print a warning:
1. year/month/day adjustments (performed on 'struct tm'),
   where 'mktime' returns a different isdst value.
2. hour/minute/seconds/ns adjustments (performed on 'time_t'),
   where the result of 'localtime(3)' on the value will return a
   different isdst value.

Note: DST changes could be harmless or unnoticeable.

Examples (with 'TZ=America/New_York'):

Unnoticeable: result is 2016-Dec-14
   $ date -d '2016-06-15 EDT + 6 months' +%b
   Dec

Unnoticeable: result is 2016-Dec-15 11:00:00
   $ date -d '2016-06-15 12:00:00 EDT + 6 months' +%F
   2016-12-15

This is unexpected:
   $ date -d '2016-06-01 EDT + 6 months' +%F
   2016-11-30

The new debug warnings will show:

   $ ./src/date --debug -d '2016-06-01 EDT + 6 months' +%F
   ...
   date: warning: daylight saving time changed after date adjustment
   ...

* lib/parse-datetime.y (parse_datetime2): Detect DST changes, and print
an appropriate warning message.
ChangeLog
lib/parse-datetime.y