dre*_*ves 0 debugging datetime wolfram-mathematica
这很奇怪:
DateList@AbsoluteTime[596523]
Run Code Online (Sandbox Code Playgroud)
回报
{2078, 7, 2, 2, 42, 9.7849}
Run Code Online (Sandbox Code Playgroud)
但
DateList@AbsoluteTime[596524]
Run Code Online (Sandbox Code Playgroud)
回报
{1942, 5, 26, 20, 28, 39.5596}
Run Code Online (Sandbox Code Playgroud)
问题:发生了什么事?请注意,带有数字参数的AbsoluteTime未记录.
(I think I now know what it's doing but figured this is useful to have as a StackOverflow question for future reference; and I'm curious if there's some reason for that magic 596523 number.)
PS: I encountered this when writing these utility functions for converting to and from unix time in Mathematica:
(* Using Unix time (an integer) instead of Mathematica's AbsoluteTime... *)
tm[x___] := AbsoluteTime[x] (* tm is an alias for AbsoluteTime. *)
uepoch = tm[{1970}, TimeZone->0]; (* unixtm works analogously to tm. *)
unixtm[x___] := Round[tm[x]-uepoch] (* tm & unixtm convert between unix & *)
unixtm[x_?NumericQ] := Round[x-uepoch] (* mma epoch time when given numeric *)
tm[t_?NumericQ] := t+uepoch (* args. Ie, they're inverses. *)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
112 次 |
最近记录: |