Will converting the difference between 2 datenums to seconds contain leap seconds or not?
Afficher commentaires plus anciens
I have a GPS logger that provides a .CSV record of location and speed for every second in the format 'mm/dd/yyyy,HH:MM:SS AM'. Assuming the date and time are in GPS time rather than UTC, when I take the datenum difference between this and the GPS epoch will the leap seconds be included or not?
GPSsecond = 24*60*60*(datenum( strTime, 'mm/dd/yyyy,HH:MM:SS AM' ) - datenum( 1980, 1, 6, 0, 0, 0 ));
Should I add the (current) 17 leap seconds or not?
Réponse acceptée
Plus de réponses (2)
the cyclist
le 21 Juil 2015
Modifié(e) : the cyclist
le 21 Juil 2015
An easy test to show that datenum does not handle this is
ds1 = '07/01/1972,00:00:00 AM';
ds2 = '06/29/1972,00:00:00 AM';
GPSsecond = 24*60*60*(datenum( ds1, 'mm/dd/yyyy,HH:MM:SS AM' ) - datenum( ds2, 'mm/dd/yyyy,HH:MM:SS AM' )) - 172800
Note that according to the Wikipedia page on leap seconds, one was inserted on June 30, 1972. So, the above test would have given 1 instead of 0 if the leap second had been in there.
5 commentaires
Carl Finney
le 21 Juil 2015
Brendan Hamm
le 21 Juil 2015
Modifié(e) : Brendan Hamm
le 21 Juil 2015
In fact the most recent was only last month on Tuesday, June 30, 2015 at 23:59:60 UTC
the cyclist
le 21 Juil 2015
I deliberately decided not to use the latest. I was unsure as to when the Time Lords decided to add leap seconds, and how long that might take to be implemented in MATLAB. That might prove to be an interesting test for Brendan's solution.
Carl Finney
le 22 Juil 2015
Steven Lord
le 22 Juil 2015
It does, as described in this Bug Report for release R2014b. Technically you could quibble about whether this is a bug, since the leap second was announced in January 2015 which was after release R2014b shipped, but I think the bug report exists mainly so we could attach a patch.
James Tursa
le 21 Juil 2015
Modifié(e) : James Tursa
le 21 Juil 2015
0 votes
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!