linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@MIT.EDU>
To: Colin Plumb <colin@nyx.net>
Cc: andrejp@luz.fe.uni-lj.si, linux-kernel@vger.rutgers.edu
Subject: Re: GPS Leap Second Scheduled!
Date: Wed, 9 Sep 1998 15:08:33 -0400	[thread overview]
Message-ID: <199809091908.PAA23948@dcl.MIT.EDU> (raw)
In-Reply-To: Colin Plumb's message of Tue, 8 Sep 1998 22:46:25 -0600 (MDT), <199809090446.WAA25923@nyx10.nyx.net>

   Date: 	Tue, 8 Sep 1998 22:46:25 -0600 (MDT)
   From: Colin Plumb <colin@nyx.net>

   The problem is that POSIX is schizophrenic on the subject of leap seconds.
   On the one hand, time() returns UTC time.  

Yep.  See POSIX 4.5.1.2, 2.2.2.77, 2.2.2.24, and the rationale for
Epoch, found in B.2.2.2).

    On the other,

	   t = time();
	   sec = t % 60;
	   t /= 60;
	   min = t % 60;
	   t /= 60;
	   hr = t % 24;
	   t /= 24;
	   printf("UTC time is %lu days, %02u:%02u:%02u\n", (unsigned long)t, gr, min, sec);

   is required to work (since so much code does it.)

In fact, POSIX requires this (see 2.2.2.77).

   Actually, I think Ulrich was present when I proposed a similar solution:
   gettimeofday() will not return during 23:59:60.  If a process calls
   gettimeofday() during a leap second, then the call will sleep until 0:00:00
   when it can return the correct result.

The other possibility is for gettimeofday() to return the same value for
23:59:60 and 00:00:00.  This would also strictly speaking be correct.
time() is specified as returning "seconds since the Epoch", which is
defined as:

	tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86400 +
		(tm_year-70)*31536000 + ((tm_year-64)/4*86400)

where tm_sec, tm_min, tm_hour, etc. together form a Curridnated
Universal Time name.

Hence, the above equation would have the same value for 23:59:60 and
00:00:00 on the next day.  Hence, time() should return the same value.

						- Ted

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/faq.html

  reply	other threads:[~1998-09-09 17:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-09  4:46 GPS Leap Second Scheduled! Colin Plumb
1998-09-09 19:08 ` Theodore Y. Ts'o [this message]
     [not found] <299BBE59294E@rkdvmks1.ngate.uni-regensburg.de>
     [not found] ` <98090822315400.00819@soda>
1998-09-09  0:59   ` H. Peter Anvin
1998-09-09  8:00     ` Chris Wedgwood
     [not found]       ` <199809092149.RAA06993@hilfy.ece.cmu.edu>
1998-09-10  1:37         ` H. Peter Anvin
1998-09-10 15:05           ` Theodore Y. Ts'o
1998-09-12 19:57           ` Feuer
1998-09-09 16:35   ` David Lang
1998-09-09 20:13 Colin Plumb
1998-09-09 23:45 ` Chris Wedgwood
1998-09-09 23:55   ` Chris Wedgwood
1998-09-10  8:36   ` Rogier Wolff
1998-09-10 17:05     ` Oliver Xymoron
1998-09-10 22:02       ` Ryan Moore
     [not found] <no.id>
1998-09-10  6:34 ` Jamie Lokier
1998-09-11  6:18   ` Michael Shields
1998-09-11 22:49 Ethan O'Connor
     [not found] <19980914165757.A17479@tantalophile.demon.co.uk>
     [not found] ` <199809150603.XAA29073@cesium.transmeta.com>
     [not found]   ` <19980915100729.02790@albireo.ucw.cz>
     [not found]     ` <35FF1838.6E247F0C@his.com>
1998-09-17 11:51       ` Jan Echternach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199809091908.PAA23948@dcl.MIT.EDU \
    --to=tytso@mit.edu \
    --cc=andrejp@luz.fe.uni-lj.si \
    --cc=colin@nyx.net \
    --cc=linux-kernel@vger.rutgers.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).