datetime - os.time() 是否使用了 isdst 字段?

标签 datetime lua dst datetimeoffset

os.date("*t")的输出中有一个isdst字段,您可以在os.time的输入中指定它。也许我是愚蠢的,但我根本看不到它被 os.time 使用:

> print(os.time{year=2016, month=3, day=29, hour=9,min=10,sec=10,isdst=1})
1459235410
> print(os.time{year=2016, month=3, day=29, hour=9,min=10,sec=10,isdst=0})
1459235410
> print(os.time{year=2016, month=6, day=29, hour=9,min=10,sec=10,isdst=0})
1467184210
> print(os.time{year=2016, month=6, day=29, hour=9,min=10,sec=10,isdst=1})
1467184210

无论您对 isdst 的规范如何,您似乎都获得了相同的大纪元时间表示。那么,忽略此字段是否安全?

最佳答案

isdst 字段是一个 bool 值,而不是数字。请注意,任何不是 falsenil 的内容都被认为是真实的,包括 0

要将isdst设置为false,尝试

print(os.time{year=2016, month=6, day=29, hour=9, min=10, sec=10, isdst=false})

isdst 字段的默认值为 nil,因此这也适用:

print(os.time{year=2016, month=6, day=29, hour=9, min=10, sec=10})

关于datetime - os.time() 是否使用了 isdst 字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36276857/

相关文章:

php - 比较来自 mysql 的 PHP 中的 2 个日期时间,以便在 android 中查看

compilation - Suricata luajit 编译错误

c++ - 具有绝对日期的夏令时更改

python - 如何根据 Python 中的日期(而不是当前语言环境)将 DateTime 转换为夏令时

java - JodaTime 从期间获取值

datetime - pandas 日期时间切片 : junkdf. ix ['2015-08-03' :'2015-08-06' ] 不起作用

R:绘制日期时查找刻度线的位置

ios - 如何访问模块中声明的变量?

python - lua cjson 无法解码特定的 unicode 字符?

php - 为 session 设置 MySQL 时区