[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
date and UTC and GMT odd behaviour
From: |
Mike 'Mike' Jones |
Subject: |
date and UTC and GMT odd behaviour |
Date: |
Tue, 23 Aug 2005 13:26:47 +0100 (BST) |
I have just noticed an anomaly with the UTC and GMT time zones in the
standard coreutils. Around the Unix epoch they are not delivering the
same times:
--At midnight:
$ date -d "Tue Jan 01 00:00:00 UTC 1970" +%s
0
$ date -d "Tue Jan 01 00:00:00 GMT 1970" +%s
-3600
--At 1am
$ date -d "Tue Jan 01 01:00:00 UTC 1970" +%s
3600
$ date -d "Tue Jan 01 01:00:00 GMT 1970" +%s
0
A little bit of trial-and-error and I find that the anomaly is limited to
between 6pm, 23 Jun 1968 GMT and 2am, 31 Oct 1971:
$ date -d "Sat Oct 31 01:59:59 UTC 1971" +%s
57722399
$ date -d "Sat Oct 31 01:59:59 GMT 1971" +%s
57718799
$ date -d "Sat Oct 31 02:00:00 UTC 1971" +%s
57722400
$ date -d "Sat Oct 31 02:00:00 GMT 1971" +%s
57722400
and
$ date -d "Sun Jun 23 18:00:00 UTC 1968" +%s
-48060000
$ date -d "Sun Jun 23 18:00:00 GMT 1968" +%s
-48063600
$ date -d "Sun Jun 23 17:59:59 UTC 1968" +%s
-48060001
$ date -d "Sun Jun 23 17:59:59 GMT 1968" +%s
-48060001
This means that using:
$ date -d "Tue Jan 01 00:00:00 GMT 1970 + NNNNN seconds"
returns dates that are one hour early. This affects scripts that
I'm writing which use credential lifetimes passed as strings encoded as
seconds since the Unix epoch.
$ date --version
date (coreutils) 4.5.3
I get the same result with date versions 5.0 and 5.2.1.
Cheers,
Mike
--
http://www.sve.man.ac.uk/General/Staff/jonesM/
smime.p7s
Description: S/MIME Cryptographic Signature
- date and UTC and GMT odd behaviour,
Mike 'Mike' Jones <=