19
$\begingroup$

AbsoluteTime supposedly reports the "total number of seconds" between two dates, but it does not. For example, because of the leap second applied at 2012-06-30T23:59:60Z,

AbsoluteTime[{2012, 7, 1}] - AbsoluteTime[{2012, 6, 29}]

should be 172,801, but it returns 172,800. In fact, Mathematica seems to ignore leap seconds altogether:

DateList[{2012, 6, 30, 23, 59, 60.5}, TimeZone -> 0]

produces {2012, 7, 1, 5, 0, 0.5} when it should produce {2012, 6, 30, 23, 59, 60.5}.

Am I missing something here? How are calculations and functions, such as AstronomicalData, that depend on accurate time specifications supposed to work?


Update: This remains the case in version 9.0 and 10.0.2.

Update: Without ever directly acknowledging this as a bug, Wolfram has now notified me that this "issue has been resolved" in 12.1 — 8 years later (though in fact it appears not to have actually been fixed).

$\endgroup$
12
  • 4
    $\begingroup$ Note that I'd be happy (well, a bit unhappy actually) with an answer that simply clarified Mathematica's concept of a "time". For example, it seems that by "time", it really means "calendar date including hours, minutes, and seconds", so that AbsoluteTime is a bit of a misnomer: it's really "DifferenceBetweenCalendarDatesConvertedToSeconds". $\endgroup$
    – orome
    Commented Nov 22, 2012 at 18:30
  • 3
    $\begingroup$ This is known to be a deficiency for a lot of years. I think it will not be changed. $\endgroup$ Commented Nov 22, 2012 at 20:08
  • 4
    $\begingroup$ @RolfMertig: So it's easy enough then (I think) to see one implication of this for AstronomicalData: leap seconds are ignored and time is just ticking away according to a uniform clock, but not UTC, so that the data reported by AstronomicalData for a given (*Mathematica) "date" will actually be the data for a different UTC date (what the world outside *Mathematica *means by "date") some seconds away. But that leaves the question: which date? $\endgroup$
    – orome
    Commented Nov 22, 2012 at 20:53
  • $\begingroup$ @RolfMertig, got a Uncompress::corrupt error on your hashed email. Can you fix? $\endgroup$ Commented Dec 11, 2014 at 17:40
  • 3
    $\begingroup$ @alancalvitti: I've tried. They got defensive and angry. Very unpleasant experience. $\endgroup$
    – orome
    Commented Dec 11, 2014 at 17:49

1 Answer 1

3
$\begingroup$

The U.S. Naval Observatory keeps a list of when leap seconds have been added and I think it has been at a stable URL for a while: http://maia.usno.navy.mil/ser7/tai-utc.dat

You could use this if you need to know when seconds were added. I wrote a solar position routine, and used this for a while, but I changed it to use an output file from their MICA software, which has a closer interpolation routine for a better approximation to solar time for the present and immediate future. Their algorithm and data are upgraded regularly, if you don't need the interpolation for current estimate, the data set above should be adequate to give you the history of when leap seconds were added.

$\endgroup$
4
  • $\begingroup$ The question is how to get AstronomicalData to report the "total number of seconds" between two dates, as claimed; not how to calculate them on one's own. $\endgroup$
    – orome
    Commented Dec 11, 2014 at 16:48
  • $\begingroup$ How to interpret the several gaps between regular intervals? years in tai-utc (year only, ignoring month) Import["http://maia.usno.navy.mil/ser7/tai-utc.dat"][[All, 1]] // NumberLinePlot $\endgroup$ Commented Dec 11, 2014 at 18:05
  • $\begingroup$ I think they add the leap second at 0:00:00 UTC on the date. They add them based on astronomical observations; the earth's rotation is not constant so the gaps vary. $\endgroup$
    – Bob R
    Commented Dec 12, 2014 at 19:31
  • $\begingroup$ Markus Roellig provides a Mathematica routine for $\Delta T$ here. $\endgroup$ Commented Aug 2, 2016 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.