Number of leap seconds


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Number of leap seconds
# 1  
Old 06-03-2009
Number of leap seconds

Is there a function call in std library or unit command that returns the number of current leap seconds?

GG
# 2  
Old 06-05-2009
No. The standard for UNIX timekeeping does not include leap seconds.

NTP servers will report correct UTC values as leap seconds are inserted.
See:
NIST Time Scale Data Archive

Here is how I would do it - this assumes your system time is actually corrected by an ntp server.

1. calculate the Julian day for Jan 1, 1970 - call it day1

2. calculate the Julian day for today -- day2

There is code to do this on this forum - search for it. Julian days == number of days since Jan 1 4712 BCE

3. use the fact there are 86400 seconds in a day.
Code:
# this works at midnight 00:00:00 hh:mm:dd
time_t leapsec=time(NULL) - ( (day2 * 86400) - day1 * 86400) );

FYI as of this date - Jun 5 2009 - leapsec = 24

corrected by jmc

Last edited by jim mcnamara; 06-05-2009 at 04:34 PM.. Reason: I can't count.
# 3  
Old 06-05-2009
Jim,

Thanks! I will search for the sample code to convert Julian days to time.

My current legacy code (but just updated) uses the number of leap seconds as 15 seconds. Where do you get 25 seconds?

GG
# 4  
Old 06-05-2009
I got 25 because I cannot count well at 4:00am my time. The correct number is 24.

Try this site -
NIST Time Scale Data Archive

-----Post Update-----

Try not to PM with questions.

Your "friend" got 15 from using GPS epoch seconds - 0000 (midnight) on Jan 6 1980.
Leap seconds started being added in 1972. So there are more leap seconds on the NIST calendar than on the GPS calendar, since GPS started with leap seconds under its belt.

TAI - UTC is now 35 seconds. So in another sense there have been 35.

Normally leap seconds are derived as changes to UTC - what computers are supposed to be synced to by the worldwide NTP service. 24 leap seconds.

Last edited by jim mcnamara; 06-05-2009 at 06:20 PM..
# 5  
Old 06-05-2009
Make sense

It makes sense. We use leap seconds to convert GPS time to UTC time.

Again thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Leap second for year 2015

I hear the Leap second for 2015 will occur on June 30 at 23:59:60 according to the wild rumours from internet the expected impact ranges from crashing to hanging servers. Can anybody share their preparations what they have done for solaris servers? are there any patches to install or workaround?... (1 Reply)
Discussion started by: sparcguy
1 Replies

2. Shell Programming and Scripting

Compare fraction number and convert duration to seconds

Hi friends, I have a file with contents below: 01.m4a 00:14:45.82, 01.mp4 00:03:46.05, -659.770000 05.m4a 00:27:43.51, 05.mp4 00:27:45.10, 1.590000 06.m4a 00:11:39.73, 06.mp4 00:11:44.60, 4.870000 If 5th column value more than 3 or less than -3 then I should get its name (from first... (2 Replies)
Discussion started by: magnus29
2 Replies

3. Fedora

Leap second happening

Have anybody heard about the Leap second problem Leap second :A leap second is a one-second adjustment that is occasionally applied to Coordinated Universal Time (UTC) in order to keep its time of day close to the mean solar time. How could i avoid such thing in my script which i deal with... (6 Replies)
Discussion started by: wnaguib
6 Replies

4. UNIX for Dummies Questions & Answers

Leap year K-shell script

I need a k-shell script that tests for leap-year. Does anyone have one at hand, need ASAP!!! (2 Replies)
Discussion started by: p1jls02
2 Replies

5. UNIX for Advanced & Expert Users

leap seconds and the stdc library

I understand the NTP protocol, so keeping system time updated is not a problem. Standard C library routines like localtime() take a number of UTC seconds elapsed since the start of the epoch (Jan 1, 1970). These times in seconds can be a filetime, system time, or some other time in the past or... (1 Reply)
Discussion started by: jim mcnamara
1 Replies

6. HP-UX

Leap Second

Hi All, We are running the HP-UX 11.11 and Linux AS 3.0. so, shall we need to make any changes for leap second i.e. insert the leap second on 1st Jan 2006 or does the system have some setup which would take care of this automatically. Please advise. Regards, Inder (1 Reply)
Discussion started by: isingh786
1 Replies

7. UNIX for Advanced & Expert Users

Insertion of Leap Second

Hi All, We are running the HP-UX 11.11 and Linux AS 3.0. so, shall we need to make any changes for leap second i.e. insert the leap second on 1st Jan 2006 or does the system have some setup which would take care of this automatically. Please advise. Regards, Inder (2 Replies)
Discussion started by: isingh786
2 Replies

8. UNIX for Advanced & Expert Users

how to get number of seconds

How do I get the number of seconds since 1970, within a script, for the previous day at 23:59? I need this value to pass into a sql statement to cleanup records older than the previous day at midnight. It will be automated via cron so no hard coding allowed. Thanks! (2 Replies)
Discussion started by: captainzeb
2 Replies
Login or Register to Ask a Question