Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are .Net's DateTime methods capable of recognising a Leap Second?

With a Leap Second on the horizon for June this year it got me wondering whether the .Net framework is leap second aware? The extra second is to be inserted after the last second of June 30th so UTC will officially be:

2012 June 30,     23h 59m 59s 2012 June 30,     23h 59m 60s 2012 July  1,      0h  0m  0s 

Is the .Net framework capable of handling this? Does it even matter if Windows is not Leap Second aware? Will this affect apps in mono running on O/S's that are Leap Second aware?

EDIT:

To expand on this a little bit i'm envisioning a scenario where a Java based solution on Linux (which is Leap Second aware) calls a .Net Web Service passing in something that is a valid timestamp in Java but is out of bounds for .Net. Are there any frameworks that cater for it (Like Noda Time perhaps)?

like image 290
Wolfwyrd Avatar asked Jan 06 '12 16:01

Wolfwyrd


2 Answers

No -

A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.

The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001, which represents DateTime.MinValue. It does not include the number of ticks that are attributable to leap seconds.

Source: http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx

like image 200
Hecksa Avatar answered Sep 24 '22 12:09

Hecksa


The .Net DateTime has no provisions for Leap Seconds, but will simply rely on the OS time. Windows is blissfully unaware of Leap Seconds(1)(2), and so will just have the notion of time as it receives it from its NTP master (I believe the default for a non-domain connected machine is time.windows.com), which is probably serving up UTC including leap seconds.

See also my answer to "Calculating Future Epoch Time in C#" which goes into more details.

  1. http://support.microsoft.com/kb/909614
  2. http://www.meinberg.de/english/info/leap-second.htm
like image 30
Peter Stuer Avatar answered Sep 22 '22 12:09

Peter Stuer