Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72049 > unrolled thread

Re: os.stat and time zones

Started byBen Finney <ben@benfinney.id.au>
First post2014-05-26 13:33 +1000
Last post2014-05-26 13:33 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: os.stat and time zones Ben Finney <ben@benfinney.id.au> - 2014-05-26 13:33 +1000

#72049 — Re: os.stat and time zones

FromBen Finney <ben@benfinney.id.au>
Date2014-05-26 13:33 +1000
SubjectRe: os.stat and time zones
Message-ID<mailman.10331.1401075206.18130.python-list@python.org>
Nagy László Zsolt <gandalf@shopzeus.com> writes:

> This might be a silly question. Documentation of os.stat:
>
> > The exact meaning and resolution of the st_atime, st_mtime, and
> > st_ctime attributes depend on the operating system and the file
> > system. For example, on Windows systems using the FAT or FAT32 file
> > systems, st_mtime has 2-second resolution, and st_atime has only
> > 1-day resolution. See your operating system documentation for
> > details.

> So it says that the meaning is platform dependent.

It says what it means: “The exact meaning and resolution of the
st_atime, st_mtime, and st_ctime attributes depend on the operating
system and the file system.”

That doesn't mean quite what you've said in your paraphrase.

> But here is something interesting. Supposedly, os.stat(fpath).st_mtime
> and os.path.getmtime(path) return the same thing.

The implementation of ‘os’ is platform-dependent. So, the meaning of the
return value of ‘os.stat’ and of ‘os.path.getmtime’ will also be
platform-dependent.

> If the above are true, then as far as I can see, the meaning of
> st_mtime is NOT platform dependent.

You've missed the part where the ‘os’ module is platform-dependent, and
hence the ‘os.stat’ behaviour is platform-dependent.

> It always means the number of seconds elapsed since the epoch in UTC.

The time elapsed doesn't change in meaning. The meaning of “modification
time” (and “creation time”, and “access time”) is what changes, because
different filesystems and different operating systems have different
meanings for those.

> So what is the truth? What other difference can be in the meaning that
> is platform dependent?

Read up on the different filesystems implemented on the operating
systems and filesystems relevant to you, and what meanings are assigned
by each specific filesystem to those timestamps.

-- 
 \       Moriarty: “Forty thousand million billion dollars? That money |
  `\            must be worth a fortune!” —The Goon Show, _The Sale of |
_o__)                                                       Manhattan_ |
Ben Finney

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web