Michael David on Sat, 8 Sep 2001 15:20:11 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Party to celebrate 10^9 seconds of UNIX?


On Tue, Aug 28, 2001 at 06:56:57PM -0400, A.N.Varady wrote:
> > Cool! Could someone explain why "date -d '1970-01-01 1000000000
> > sec'" yields the "incorrect" time?

On Tue, 28 Aug 2001, Walt Mankowski wrote:
> "date -d 1970-01-01" gives clue:
>
>       Wed Dec 31 00:00:00 EST 1969
>
> Epoch time starts at midnight, January 1, 1970, GMT.  You're starting
> from midnight EST, which is GMT + 5 hours.  Then date converts it to
> EDT, which is an hour later than EST, and that's why it overshoots GMT
> by an hour.

This looks like a bug to me. It seems that GNU date applies
a "spring forward" (+3600 seconds) to the seconds count when
DST is in effect. This doesn't make sense because the
seconds count has no time zone, and DST is a change of time
zone, not a change in the time.

The steps I took:

$ date -d "01/01/1970 00:00:1000000000 UTC"
Sat Sep  8 22:46:40 EDT 2001

This is an hour later than the time everyone is talking
about. What is that time in seconds?

$ date -d "01/01/1970 00:00:1000000000 UTC" +%s
1000003600

Hmm. Looks like an extra hour got added. Let's subtract
that.

$ date -d "01/01/1970 00:00:1000000000 UTC -1 hour" +%s
1000000000

OK, that's the seconds count we were looking for. What's
that in local time?

$ date -d "01/01/1970 00:00:1000000000 UTC -1 hour"
Sat Sep  8 21:46:40 EDT 2001

Now we're agreeing with the others.

According to the man page date(1):

       %s     seconds since 00:00:00, Jan 1, 1970 (a GNU extension)

This doesn't mention a time zone, so it might reasonably be
interpreted as "seconds since 00:00:00 Jan 1 1970 in your
local time." Only they don't exactly do that either. It's
more like:

       %s seconds since 00:00:00, Jan 1, 1970 UTC, assuming
your wall clock time is standard time for your local time
zone, even if it's not. (a GNU bug)

This is neither what they documented, nor what I would have
expected.

--mvd

-- 
Michael V. David, AAO (Acronym Assignment Officer), NewEarth Swedenborg BBS
michael@newearth.org - http://www.newearth.org/~michael - Penguin 2.4.9-xfs
Code Red Worm Report: http://mvdavid.com/info/codered/
"640K ought to be enough for anybody." -- Bill Gates, 1981


______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug