带有数字参数的AbsoluteTime表现奇怪

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)

rag*_*eld 5

如果您将596524和596523从小时转换为秒(乘以3600),您将看到较大的数字大于2 ^ 31-1(最大32位有符号整数值),而较小的数字则不是.