sangan1161
Posts: 1
Joined: Sun Jan 03, 2016 4:45 am

Keep time: leap second?

Sun Jan 03, 2016 4:51 am

Hi guys, I have a little question: how can en RTC system manage leap seconds?

In this case I could have system time set to 00:00:00 while correct time would be 23:59:60.
I've read GPS correctly manages this, but when working with ntp?
Does it support leap second? I haven't found any library about this......
At same time never heard before about RTC supporting leap second.
Any ideas?
Thanks.

______________
toyota ly thuong kiet uy tin, dich vu son epoxy gia re, thi cong son epoxy chuyen nghiep.
dich vu rut ham cau gia re
Last edited by sangan1161 on Thu Mar 03, 2016 1:20 am, edited 3 times in total.
:D

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Keep time: leap second?

Sun Jan 03, 2016 7:16 am

As you surmised, RTCs don't know anything about leap seconds, so, it comes down to the OS. I'm guessing that Linus Torvalds' reference Linux kernel, Debian, and hence Raspbian and Ubuntu (which both derive from Debian) both implement the following via the Network Time Protocol, and occasional access to NTP servers over a network is available to detect the change:
http://www.ntp.org/ntpfaq/NTP-s-algo-real.htm#AEN2499
The theory of leap seconds in explained in Q: 2.4.. In reality there are two cases to consider:

If the operating system implements the kernel discipline described in Section 5.2, ntpd will announce insertion and deletion of leap seconds to the kernel. The kernel will handle the leap seconds without further action necessary.

If the operating system does not implement the kernel discipline, the clock will show an error of one second relative to NTP's time immediate after the leap second. The situation will be handled just like an unexpected change of time: The operating system will continue with the wrong time for some time, but eventually ntpd will step the time. Effectively this will cause the correction for leap seconds to be applied too late.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

User avatar
jojopi
Posts: 3078
Joined: Tue Oct 11, 2011 8:38 pm

Re: Keep time: leap second?

Sun Jan 03, 2016 7:19 am

RTC chips do not handle leap seconds. GPS time does not even have leap seconds, but the difference to UTC is broadcast, so the presence of leap seconds in UTC can be inferred.

Linux and NTP have limited support for leap seconds. The system time will never be 23:59:60, but the clock will warp so that some second around that time is repeated. Some time after that, any RTC should be updated.

Correct handling of leap seconds in POSIX is hampered by the assumption that you can divide the number of seconds since 1970-01-01 by 86400 to get the number of days.

Future systems may stretch time around the leap second, instead of inserting a discontinuity.

User avatar
DougieLawson
Posts: 35378
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Keep time: leap second?

Sun Jan 03, 2016 12:23 pm

It may not matter. The leap second on 30th June 2015 may be the last one ever although we've got to wait until 2023 for the science wonks to make their minds up.

http://news.nationalgeographic.com/2015 ... k-science/
http://www.nature.com/news/leap-second- ... rs-1.18855

Mainframes have code in their OS to spin the processor doing nothing productive for a second when a leap second is added.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

W. H. Heydt
Posts: 10341
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Keep time: leap second?

Sun Jan 03, 2016 5:42 pm

I'm inclined to think that a leap second correction in an RTC would be an exercise in frustration since I don't know of an RTC that is practical for individual use (i.e. cost is affordable by Mere Mortals) that would be accurate enough to tell if it were only off by one second after a year of running without correction.

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Keep time: leap second?

Mon Jan 04, 2016 12:15 pm

I'm for losing leap seconds and moving the meridian ... :D

Long live UTC
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Keep time: leap second?

Mon Jan 04, 2016 1:14 pm

I didn't know those seconds! :shock:

W. H. Heydt
Posts: 10341
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Keep time: leap second?

Mon Jan 04, 2016 3:19 pm

allfox wrote:I didn't know those seconds! :shock:
The reason for them is that we can now make clocks that are more consistent than the rotation of the Earth. This is a comparatively modern problem.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Keep time: leap second?

Mon Jan 04, 2016 3:59 pm

W. H. Heydt wrote:
allfox wrote:I didn't know those seconds! :shock:
The reason for them is that we can now make clocks that are more consistent than the rotation of the Earth. This is a comparatively modern problem.
Compared to the invention of clocks yes.
Nuclear clocks have been around for a good while now.
Doug.
Building Management Systems Engineer.

gordon77
Posts: 4003
Joined: Sun Aug 05, 2012 3:12 pm

Re: Keep time: leap second?

Mon Jan 04, 2016 4:24 pm

BMS Doug wrote:
W. H. Heydt wrote:
allfox wrote:I didn't know those seconds! :shock:
The reason for them is that we can now make clocks that are more consistent than the rotation of the Earth. This is a comparatively modern problem.
Compared to the invention of clocks yes.
Nuclear clocks have been around for a good while now.
Depends what you call modern, atomic clocks came in 1950s, started adding leap seconds in 1972.

W. H. Heydt
Posts: 10341
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Keep time: leap second?

Mon Jan 04, 2016 4:32 pm

BMS Doug wrote:
W. H. Heydt wrote:
allfox wrote:I didn't know those seconds! :shock:
The reason for them is that we can now make clocks that are more consistent than the rotation of the Earth. This is a comparatively modern problem.
Compared to the invention of clocks yes.
Nuclear clocks have been around for a good while now.
That's why I said "comparatively modern". First Cesium transition clock was made in 1955, and I'm older than that. Granted...the idea was first proposed by Lord Kelvin in 1879, which is--essentially--when my grandparents were born, but actual attempts to build atomic transition clocks only really got going in the 1930s.

I suppose what constitutes "modern" depends on the speaker's age...

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Keep time: leap second?

Mon Jan 04, 2016 4:59 pm

W. H. Heydt wrote:
BMS Doug wrote:
W. H. Heydt wrote: The reason for them is that we can now make clocks that are more consistent than the rotation of the Earth. This is a comparatively modern problem.
Compared to the invention of clocks yes.
Nuclear clocks have been around for a good while now.
That's why I said "comparatively modern". First Cesium transition clock was made in 1955, and I'm older than that. Granted...the idea was first proposed by Lord Kelvin in 1879, which is--essentially--when my grandparents were born, but actual attempts to build atomic transition clocks only really got going in the 1930s.

I suppose what constitutes "modern" depends on the speaker's age...
It depends what you are comparing to, which was why I gave a comparison point.
Doug.
Building Management Systems Engineer.

Return to “General discussion”