[Tutor] python3 equivalent of coreutils stat command
Alan Gauld
alan.gauld at btinternet.com
Sat Jun 14 23:52:25 CEST 2014
On 14/06/14 22:06, street.sweeper at mailworks.org wrote:
> With the stat command in GNU coreutils, I can get a file's
> modification time, with timezone offset.
> gotten close with os.path.getmtime and os.stat, for example
> 2014-02-03T14:48:17. But, no timezone offset.
os.stat returns the mtime as seconds from the epoch.
The time and datetime modules contain functions for converting
seconds into local time etc which can show timezone if needed.
But be aware of the following caveat from the documentation:
-----------
Note: 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.
...
-------------------
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list