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

Paul Gearon gearon at computer.org
Wed Dec 29 02:02:04 EST 1999


[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics.  Please observe the list's charter.          ]

>> I'm sure you can find good calendar libraries in your favourite
>> language.  It seems silly to reimplement it.  For financial applications
>> the Mac-style "uint32 days since 1904" might be good, and it neatly
>> avoids leap seconds altogether.
>>
>
>Well yes, that is where this all started for me.
<snip>

Well I can't comment on leap-seconds (as I don't know when they occur), but
in terms of determining time differences between consecutive days, then
difftime is fine.  All it really does is take one time_t away from another.
Since time_t is an absolute count of seconds since midnight Jan 1 1970, then
all difftime does is work out how many seconds difference there is between
two given times.  If it's greater than or equal to 86400 then it's one day
or more, and if it's less than 172800 then it's less than 2 days.  It
doesn't matter if it includes a leap day or not since the number of seconds
doesn't change.

I really wouldn't bother with a library for something as trivial as this....
(unless leap seconds are a concern?  BTW, when ARE they?)

Regards,
Paul

Paul Gearon
Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane
mittam.
(Translation from latin: "I have a catapult. Give me all the money, or I
will fling an enormous rock at your head.")


--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list