文件系统是否存储时区信息?

编程入门 行业动态 更新时间:2024-10-23 13:35:25
本文介绍了文件系统是否存储时区信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

文件系统是否将时区信息与文件信息一起存储?我遇到了一个奇怪的错误,我在执行以下代码段时会打印出不同的时区.

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

它在进行夏令时更改后开始发生.我看到东部和格林威治标准时间 -4.IIRC Linux 不存储时间戳信息,而是将时间存储为从 1970 年 1 月 1 日起经过的绝对秒数.

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.

某些文件系统是否可能存储时区信息?我被告知 DST(夏令时)是通过使用不同的时区来表示的.那么在夏令时或一般情况下 - 这些元数据是否由文件系统存储?

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?

例如:https://rsync.samba/daylight-savings.htm 指出 FAT 存储夏令时信息.

For eg: https://rsync.samba/daylight-savings.htm points out that FAT stores Daylight Saving Information.

因为根据接受的答案,两者都是相同的时区,是否可以将 GMT -4 显示为东部夏令时以使最终用户真正清楚地了解情况?

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?

推荐答案

我不知道有任何文件系统可以存储时区信息及其时间戳.根据文件系统/操作系统,它要么以 UTC 时间存储,要么以本地时间存储.

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 的 DateTime 将使用您的本地时区,除非您指定其他内容.

Zope's DateTime will use your local timezone unless you specify something else.

美国/东部在夏令时是格林威治标准时间 -4,所以这可能是正确的.

US/Estern is GMT -4 during daylight savings, so this is probably correct.

这篇关于文件系统是否存储时区信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 09:57:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1391976.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件系统   时区   信息

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!