Looking for a tool to make UNIX-Time

John F. Haugh II jfh at rpp386.cactus.org
Fri Nov 30 03:24:54 AEST 1990


In article <1990Nov29.040427.15103 at cerberus.bhpese.oz.au> Sm at cerberus.bhpese.oz.au (Scott Merrilees) writes:
>But then you have to know all the garbage about when daylight savings
>time cuts in/out, leap years etc.  This solution is simple, has a
>few guesses, and will work anywhere without telling it extra stuff.
>It may not be terribly efficient, but probably won't be called that
>often.  I like both it, and the side step to think of doing it that
>way.

I'm really sorry that you and Gregory have decided to attack my
suggestion without trying to do anything with it.

The code correctly gets within 48 hours of the day you want,
regardless of leap years, time zones, daylight savings time,
etc.  All that is left is figuring out how many hours off
the guess was.  That is very trivial and only requires one
or two calls to localtime to get.  It is very easy to figure
out the difference between two very close dates, so the hours
fall out very quickly.  Extending to support hours, minutes
and seconds is painless.

Sure, the original posted solution is "correct", but then
so would be starting at 0 and counting up by ones.  Binary
approximation is a very old technique.  It is not new or
clever.  It is a lazy solution to a really simple problem.
Clever would have been binary approximation using whole
hours or days, both of which would have been an improvement
and would have shown some thought.

As for not being called all that often, what if the application
is something like "expire" which must deal with textual dates
in article headers?  Still think it won't be called that often?
-- 
John F. Haugh II                             UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 832-8832                           Domain: jfh at rpp386.cactus.org
"SCCS, the source motel!  Programs check in and never check out!"
		-- Ken Thompson



More information about the Alt.sources.d mailing list