Seconds from 19xx to Date (and visa

Mike Albaugh albaugh at dms.UUCP
Sat Oct 8 03:51:10 AEST 1988


>From article <7618 at rpp386.Dallas.TX.US>, by jfh at rpp386.Dallas.TX.US (The Beach Bum):
> In article <44100014 at hcx2> danr at hcx2.SSD.HARRIS.COM writes:
>>>   Does anyone have a routine to change back and forth between
>>>seconds from 19xx to a Year, Month, Day sort of Date?  
>>
>>	You might want to look at the man page for ctime(), if you have 
>>access to one.  it is in the standard library, so you don't need to write 
>>anything bu the function call.
> 
> I'd forgotten completely about unctime [ emitc ] which was recently posted.

	Well... If you guys already have library routines for both
directions, you may wish to have some fun. I already sent Tim Pozar some
non-library stuff I wrote to do this on an embedded system (no library),
and in the course of testing it discovered some "interesting" behavior
of the VAX11C ctime(). Before you unlimber your flamethrowers about
people who are dumb enough to use VMS, I would like to point out that
friends of mine were prompted by my discovery to check out their own
various systems. ONE (I forget which) did what "people" expected
even when the msb of the time was one. ONE more (I think it was SUNOS)
did a plausible (and ANSI mandated, as I read the "not-yet-standard")
thing and returned a negative date (i.e. before 1970). ALL the rest
we tried did very strange things after about 2038 (+/- 3 yrs). A few
muffed as early as 2000. Just write a little for loop that adds a days
worth of seconds to the binary time and do a sanity check on ctime().
Have fun :-)

| Mike Albaugh (albaugh at dms.UUCP || {...decwrl!turtlevax!}weitek!dms!albaugh)
| Atari Games Corp (Arcade Games, no relation to the makers of the ST)
| 675 Sycamore Dr. Milpitas, CA 95035		voice: (408)434-1709
| The opinions expressed are my own (Boy, are they ever)



More information about the Comp.lang.c mailing list