Subject: Date: Possible bug in ISO-8601 formatted dates

From: Dotan Cohen <[email-masked]>
Date: Sun, 8 Jan 2012 19:22:09 +0200

It seems that ISO-8601 formated dates are not properly handled by the
date utility. The date utility seems to erroneously add
timezone-shifting when using ISO-8601 dates. This example is fine (see
the date roundtrip to back where it started):
✈saturn:~$ date +%s -d "2006-12-31 22:00"
1167595200
✈saturn:~$ date -d @1167595200
Sun Dec 31 22:00:00 IST 2006

However, adding a "t" between the date and hour (as per ISO 8601)
breaks the roundtrip (the timestamp is wrong):
✈saturn:~$ date +%s -d "2006-12-31t22:00"
1167577200
✈saturn:~$ date -d @1167577200
Sun Dec 31 17:00:00 IST 2006

This is on a love-to-hate Debian-based distro, with GNU coreutils 8.5.
I can confirm the issue on CentOS with date 5.97. Without the "t" the
timestamp is correct:
[root@gs beer]# date +%s -d "2006-12-31 22:00"
1167602400
[root@gs beer]# date -d @1167602400
Sun Dec 31 22:00:00 UTC 2006

And with it, the timestamp is wrong.
[root@gs beer]# date +%s -d "2006-12-31t22:00"
1167577200
[root@gs beer]# date -d @1167577200
Sun Dec 31 15:00:00 UTC 2006

Note that IST (from the first server) is UTC+2.

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com