[comp.sys.apple] date converter

dcw@sun-bear.lcs.mit.edu (David C. Whitney) (01/08/90)

Does anyone have a quick and dirty algorithm for converting a date
stored as a certain number of seconds to MM/DD/YY HH:MM:SS and
vice-versa?  Thanks.

--
Dave Whitney
dcw@sun-bear.lcs.mit.edu  ...!mit-eddie!sun-bear!dcw  dcw@athena.mit.edu
My employer pays me well. This, however, does not mean he agrees with me.
I wrote Z-Link & BinSCII. Send me bug reports. I use a //GS. Send me Tech Info.

huang@husc4.HARVARD.EDU (Howard Huang) (01/10/90)

>Does anyone have a quick and dirty algorithm for converting a date
>stored as a certain number of seconds to MM/DD/YY HH:MM:SS and
>vice-versa?  Thanks.
>
>--
>Dave Whitney
>dcw@sun-bear.lcs.mit.edu  ...!mit-eddie!sun-bear!dcw  dcw@athena.mit.edu

The GS may have a toolbox routine for doing this.  I think the Mac (Ha!)
does.

ANSI C is supposed to support the conversion of seconds, but I believe
the actual details are machine-dependent.  The Mac, for example, stores
seconds since Jan. 1, 1900 or 1901.

If all else fails, you can do a bunch of divides and modulos :^)


Howard C. Huang
huang@husc4.harvard.edu

gwyn@smoke.BRL.MIL (Doug Gwyn) (01/10/90)

In article <1184@husc6.harvard.edu> huang@husc4.UUCP (Howard Huang) writes:
>ANSI C is supposed to support the conversion of seconds, but I believe
>the actual details are machine-dependent.

This is wrong.  ANSI C time conversion involves an implementation-
dependent representation of time as a time_t data type, which need
not have any simple relationships to seconds since some epoch.  The
Standard C functions clock() and difftime() do produce some form of
time in seconds, but these do not involve conversion to or from
either a character representation of time or a struct tm (a "broken-
down time", i.e. a collection of seconds, minutes, etc. component
parts).

IEEE Std 1003.1 (POSIX) and UNIX do impose the additional requirement
that time_t be expressed in seconds since a particular epoch; however
this is not an ANSI C requirement.

cyliao@eng.umd.edu (Chun-Yao Liao) (01/12/90)

In article <1184@husc6.harvard.edu> huang@husc4.UUCP (Howard Huang) writes:
>>Does anyone have a quick and dirty algorithm for converting a date
>>stored as a certain number of seconds to MM/DD/YY HH:MM:SS and
>>vice-versa?  Thanks.
>>
>>--
>>Dave Whitney
>>dcw@sun-bear.lcs.mit.edu  ...!mit-eddie!sun-bear!dcw  dcw@athena.mit.edu
 
I remember that I saw a short "One-Liner" basic program did the job...
well, It's in nibble magazine, but I have no idea in which issue it was.
All I can tell is that you probably can locate this little program in
1989 Jan-Jul issue of Nibble. Does anybody knows where exactly is this little
program located in Nibble? 
--
|I want Rocket Chip 10 MHz, Z-Ram Ultra II, UniDisk 3.5 | cyliao@wam.umd.edu  |
|I want my own NeXT, 64 Mb RAM, 660 Mb SCSI, NeXT laser |    Chun Yao Liao    |
|              printer, net connection, software, etc.  | Accepting Donations!|
/* If (my_.signature =~ yours)  coincidence = true; else ignore_this = true; */