【发布时间】:2019-04-07 18:30:24
【问题描述】:
阅读encode-time 和decode-time 的文档后,我不明白它们是如何工作的。
我的麻烦来自 encode-time 返回 两个 值,而我只期望一个(自 UNIX 纪元以来的秒数)。这两个值究竟是什么意思?
ELISP> (encode-time 0 0 0 1 1 1970 t)
(0 0)
ELISP> (encode-time 0 0 0 1 1 1971 t)
(481 13184)
我更加困惑,因为这三个调用有效,但我不明白如何解释前两种情况的参数:
;; Ok this is what I expect from the documentation
ELISP> (decode-time
(encode-time 0 0 0 1 1 1971 t))
(0 0 0 1 1 1971 5 nil 0)
;; This is also what I expected, given it's the same than above, but I don't understand the meaning of the arguments
ELISP> (decode-time '(481 13184))
(0 0 0 1 1 1971 5 nil 0)
;; I kind of understand the following: here 481 is considered the seconds since UNIX epoch,
;; and 13184 is the difference in seconds from UTC.
;; The returned value, is the date (UNIX epoch + 481 seconds)
;; expressed in a timezone 13184 seconds ahead of UTC (45 47 3 1 1 1970 = 13665 seconds
;; and 13665−13184 = 481)
ELISP> (decode-time 481 13184)
(45 47 3 1 1 1970 4 nil 13184)
请注意,对于上面的所有示例,我都设置了(set-time-zone-rule t) 以避免处理时区。
【问题讨论】:
标签: elisp