问题
Do filesystems store time zone information along with the file information? I ran into a weird bug where I do the following snippet and I get different time zone printed out.
import DateTime #zope's module
for each in os.listdir("director"):
print DateTime.DateTime(os.stat(each)[8])
#Why is it mixed up?
Foo 12:00:00 US/Eastern
Bar 12:00:00 GMT -4
It started to happen after Daylight Saving changes were made. I see Eastern and GMT -4 both. IIRC Linux doesn't store the time stamp information, instead it stores time as absolute seconds elapsed from Jan 1st 1970.
Is it possible that some file systems store time zone information? I was informed that DST (Daylight Saving Time) is expressed by using different timezones. So in day light saving scenario or in general - are these meta data's stored by file-system?
For eg: https://rsync.samba.org/daylight-savings.htm points out that FAT stores Daylight Saving Information.
Since as per the accepted answer both are same time zones, is it possible to show GMT -4 as Eastern Daylight Savings Time to make things really clear to the end user?
回答1:
I'm not aware of any file system that store timezone information with their timestamps. Depending on the file system / operating system it's either stored in UTC, or in the local time.
Zope's DateTime will use your local timezone unless you specify something else.
US/Estern is GMT -4 during daylight savings, so this is probably correct.
来源:https://stackoverflow.com/questions/30119732/do-filesystems-store-time-zone-information