AbsoluteTime with numeric argument behaves strangely.
- by dreeves
This is strange:
DateList@AbsoluteTime[596523]
returns
{2078, 7, 2, 2, 42, 9.7849}
But
DateList@AbsoluteTime[596524]
returns
{1942, 5, 26, 20, 28, 39.5596}
The question: What's going on?
Note that AbsoluteTime with a numeric argument is undocumented.
(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. *)