On 03-Nov-99, [EMAIL PROTECTED] wrote:
> Hello,
> On 28-Oct-99, [EMAIL PROTECTED] wrote:
>
>>
>> While we're on the subject of optimization, how about this?
>>
>> now - 1-1-1970 * 86400
>
>>> In Perl <*shudder*> and Unix, you can use the number of seconds from the
>>> Epoch (January 1, 1970) in programs. How can I do this in Rebol; i.e.
>>> get the number of seconds from the Epoch?
>
> I didn't try the intermediate one, but this, run several times, gives:
>
>>> now - 1-1-1970 * 86400
> == 941500800
>>> now - 1-1-1970 * 86400
> == 941500800
>>> now - 1-1-1970 * 86400
> == 941500800
>>> now - 1-1-1970 * 86400
> == 941500800
>>> now - 1-1-1970 * 86400
> == 941500800
>
> If we're talking seconds from epoch, why do these all give the same results
> when run a few seconds apart?
epoch: func [] [
x: (* now - 1-1-1970 86400) + now/time ; returns a time! value
x/3 + ((x/1 * 60) + x/2 * 60) ; converts to seconds, would be nice
; if (to integer! x) worked...
]
## epoch
== 941638664
## epoch
== 941638667
is the shortest I can come up with...
I think it would be logical if (to integer!) returned the number of seconds,
but it doesn't...
Also, I think it's intiutive that two dates subtracted returns the difference
in days, but when a time is in one of the dates, it would probably be better
if the number returned was a real number. One could allways use now/date if
time shouldn't be considered.
(REBOL 2.1.90.1.1)
Best regards
Thomas Jensen