[H-GEN] time in C/C++

Anthony Towns aj at azure.humbug.org.au
Tue Dec 28 22:02:05 EST 1999


On Wed, Dec 29, 1999 at 10:22:54AM +1000, Raymond Smith wrote:
> On Tue, 28 Dec 1999, Frank Brand wrote:
> > The divisor is 86,400 if you want to convert to days - time_t results
> > in seconds and there are 86,400 in a day.
> [...] 
> > I recall reading a text that said that there may be some inaccuracies
> > in UNIX and it would be better to write your own function (don't
> > exactly know why but that is what was said).
> I believe there are some problems with leap seconds in UTC and the
> calendar, which does not believe in leap seconds. Although I suspect that
> the difference is neither here nor there over short periods of less than a
> year.

time_t's ignore leap seconds. (If you're doing stuff with times *during*
a leap second, and you're using ntp or something similar that will tell you
about leap seconds, your time will go from 23:59:59 to 23:59:60 to 23:00:00,
with the time_t's of the latter two being the same.

Intriguingly, according to the time(2) manpage:

NOTES
       POSIX.1  defines  seconds since the Epoch as a value to be
       interpreted as the number of seconds between  a  specified
       time  and the Epoch, according to a formula for conversion
       from UTC equivalent to conversion on the naïve basis  that
       leap  seconds are ignored and all years divisible by 4 are
       leap years.

Note: *all* years divisible by 4 are leap years. No 100 or 400 rule.

Whether this is true or not is another matter...

Cheers,
aj

-- 
Anthony Towns <aj at humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. GPG encrypted mail preferred.

 ``The thing is: trying to be too generic is EVIL. It's stupid, it 
        results in slower code, and it results in more bugs.''
                                        -- Linus Torvalds
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 350 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/19991229/826df852/attachment.sig>


More information about the General mailing list