Is there a way to get AbsoluteTime to correctly report absolute time differences?

18

6

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).

orome

Posted 2012-11-22T16:38:11.790

Reputation: 12 197

@RolfMertig, got a Uncompress::corrupt error on your hashed email. Can you fix? – alancalvitti – 2014-12-11T17:40:04.413

@raxacoricofallapatorius, why not report this to WRI tech support linking to this page? Since they have Big Data / Analytics ambitions, the public forum might help to keep them honest. – alancalvitti – 2014-12-11T17:44:46.033

3@alancalvitti: I've tried. They got defensive and angry. Very unpleasant experience. – orome – 2014-12-11T17:49:05.157

4Note 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". – orome – 2012-11-22T18:30:06.070

3This is known to be a deficiency for a lot of years. I think it will not be changed. – Rolf Mertig – 2012-11-22T20:08:01.287

4

@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?

– orome – 2012-11-22T20:53:34.837

I still get 172800 in version 12.1.1. So has it been resolved? – Szabolcs – 2020-06-29T14:37:58.203

@Szabolcs: They say they "believe that the issue has been resolved in the current 12.1 release of Mathematica", which is about as oblique and non-committal as it gets. Honestly I completely fail to understand the Wolfram culture (or perhaps cult). – orome – 2020-06-29T14:40:30.730

@Szabolcs Sure enough, it's not fixed, just "resolved". – orome – 2020-06-29T14:44:15.183

@Szabolcs: More precisely: Wolfram simply redefined what is meant by AbsoluteTime. It neither corresponds to POSIX time, nor to any astronomical timekeeping system (so Mathematica can't be used for astronomy). I'm done. Dealing with Wolfram's "support" is like dealign with a Trump press secretary. – orome – 2020-06-30T12:01:20.840

It is at least documented now. In the details and options section for Absolute Time is "The number of seconds returned by AbsoluteTime does not take into account leap seconds." – Brian – 2021-01-14T21:04:52.553

Just over 8 years. Not bad for Wolfram! (I guess that just documenting rather than fixing allowed them to address this so quickly.) – orome – 2021-01-14T21:15:39.347

Answers

3

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.

Bob R

Posted 2012-11-22T16:38:11.790

Reputation: 135

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. – orome – 2014-12-11T16:48:55.020

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 – alancalvitti – 2014-12-11T18:05:01.780

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. – Bob R – 2014-12-12T19:31:05.237

Markus Roellig provides a Mathematica routine for $\Delta T$ here.

– J. M.'s ennui – 2016-08-02T08:24:17.987