Dates UTC + offset is non meaningful...?

Jason Harris jason at jasonfharris.com
Mon Nov 15 05:25:05 CST 2010


Hi All,

I just want to check if I am missing groking something about the dates mercurial is reporting.

In looking at the hg documentation on date times and times it says: 

       hgdate Date. Returns the date as a pair of numbers: "1157407993  25200"
              (Unix timestamp, timezone offset).

But what is the timezone offset for?

The standard unix timestamp is UTC standard. Ie very close to GMT time. There is no time zone involved as far as I can tell... http://en.wikipedia.org/wiki/Unix_time

(I was actually doing something with this time zone and I realized that it was causing a time display bug in MacHg http://bitbucket.org/jfh/machg/issue/110/p2d2-problem-with-time)

In my code I have the conversion:

+ (NSDate*)   dateWithUTCdatePlusOffset:(NSString*)utcDatePlusOffset

This is a method I added to the date classes to parse utcDatePlusOffset strings like the one above or the one you get from date:

hg log --template "{rev} : {date}\n"
16 : 1289811657.0-3600
15 : 1289780610.0-3600
12 : 1278270662.0-7200
10 : 1274539942.0-7200
9 : 1267843485.0-3600
...

Well looking at this, the timezone offset, shouldn't be used in calculations. That is, the time 1289811657.0 specifies the time in seconds that have passed since 1 January 1970 (1970-01-01T00:00:00Z) (ignoring leap seconds, etc which the wiki article goes on about...), thus why is it included? Is it important for some clients or would it be equivalent to just output:

16 : 1289811657.0
15 : 1289780610.0
12 : 1278270662.0
10 : 1274539942.0
9 : 1267843485.0

(I could well be missing something and it could be important...)

Thanks!
  Jason


More information about the Mercurial-devel mailing list