On Thu, Feb 23, 2012 at 3:47 PM, Larry Hastings <larry@hastings.org> wrote:
On 02/23/2012 02:35 PM, Victor Stinner wrote:
For os.stat(), you should use the UTC timezone, not a naive datetime.
Why is that more appropriate? IIUC, timestamps ignore leap seconds and strictly represent "seconds since the epoch". In order to correctly return a time in the UTC time zone we'd have to adjust for leap seconds. Naive datetimes bask in their happy ignorance of such complexities.
You seem to have the meaning of "ignore leap seconds" backwards. POSIX timestamps are not *literally* seconds since the epoch. They are *non-leap* seconds since the epoch, which is just what you want. IOW the simple calculation ignoring leap seconds (found e.g. in calendar.py) will always produce the right value. -- --Guido van Rossum (python.org/~guido)