[REBOL] Re: date/time subrtaction ?
From: dlhawley::home::com at: 16-Nov-2000 21:50
I'm a bit confused about subtraction of date/time objects. Part of the problem is that
there seem to be 3 types invloved here:
and what i'll call
The latter is returned by now and behaves differently from a date! object although
>> type? now
The difference is reflected in the following:
>> dt: now
>> d: now/date
>> type? d
>> type? dt
Now add 10 seconds to each:
>> dt + 0:00:10
>> d + 0:00:10
** Script Error: Cannot use add on date! value.
** Where: d + 0:00:10
So d and dt are a bit different.
Now on to subtraction:
>> d2: dt + 1 ; add 1 day
>> d2 - dt
== 1 ; OK, I can live with that
>> d2: dt + 0:0:10 ; add 10 seconds
>> d2 - d
I guess I sort of expected to see d2 - d == 0:0:10
Now back to the difference between date and date/time.
It is often nice to figure out date/times based on seconds from nidnight. Is there a
better method than the following:
midnight-and-3-hours: to-date rejoin [ n "/" v ]
I suppose that this might make sense:
midnight: to-date rejoin [ now/date "/" 0:0 ]
David L. Hawley D.L. Hawley and Associates 1.503.274.2242
Software Engineer [David--L--Hawley--computer--org]