Gee, Francois, a mere 20 minute discreptancy over 30 years? Isn't that
close? <g>

Okay, okay... there was a small mistake in handling remainders. I was
multiplying by 100 when it should have been by 60 for units of time ....
Thanks for pushing me into finding it.

This should work for you now:


REBOL [
        Title: "Convert Epoch Time to Date"
        Author: "Ralph Roberts"
        File: %epoch-to-date.r
        Date: 21-Feb-2000
        Purpose: {converts UNIX Epoch time (seconds after 1-1-1970)
                        to current date and time }
        Example: {outputs "Epoch date 951142987 is 21-Feb-2000
                14:38:52 GMT or 9:38:52 Local" }
        ]

        epoch: 951505087

        days: divide epoch 86400

        days2: make integer! days

        time: (days - days2) * 24
        hours: make integer! time
        minutes: (time - hours) * 60
        minutes2: make integer! minutes
        seconds: make integer! (minutes - minutes2) * 60
        time2: make time! ((((hours * 60) + minutes2) * 60) + seconds)

prin ["Epoch date" epoch "is" 1-Jan-1970 + days2 time2]
print [" GMT or" time2 + now/zone "Local"]







> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 25, 2000 6:05 AM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] unix timestamp conversion? Re:(2)
>
>
> Will this script, submitted to the mailing list take into account
> leap years etc....or will there be a small descrepency?
>
> Cheers
>
> Francois
>
>
> On Mon, 21 Feb 2000 [EMAIL PROTECTED] wrote:
>
> >
> > > Anyone written a script to convert unix timestamps (is 950618412) to
> > > a usable rebol date and time format.
> > >
> > > Cheers
> > >
> > > Francois
> > >
> > >
> >
> > Hi Francois:
> >
> > Try this.
> >
> >
> > REBOL [
> >         Title: "Convert Epoch Time to Date"
> >         Author: "Ralph Roberts"
> >         File: %epoch-to-date.r
> >         Date: 21-Feb-2000
> >         Purpose: {converts UNIX Epoch time (seconds after 1-1-1970
> >                     to current date and time }
> >         Example: {outputs "Epoch date 951142987 is 21-Feb-2000
> >             14:38:52 GMT or 9:38:52 Local" }
> >         ]
> >
> >         epoch: 951142987
> >
> >         days: divide epoch 86400
> >
> >         days2: make integer! days
> >
> >         time: (days - days2) * 24
> >         hours: make integer! time
> >         minutes: (time - hours) * 100
> >         minutes2: make integer! minutes
> >         seconds: make integer! (minutes - minutes2) * 100
> >         time2: make time! ((((hours * 60) + minutes2) * 60) + seconds)
> >
> > prin ["Epoch date" epoch "is" 1-Jan-1970 + days2 time2]
> > print [" GMT or" time2 + now/zone "Local"]
> >
>

Reply via email to