[REBOL] Re: ANN: subtract-dates
From: rebol-list2:seznam:cz at: 8-Jun-2003 21:31
Hello Boleslav,
Sunday, June 8, 2003, 6:52:03 PM, you wrote:
BB> ???
BB> what's wrong with
>>> now - 1-1-2003
BB> == 158
This is number of days! I need to count with bigger precision. That's
why subtract-dates returns time! datatype.
If you wonder what I'm counting... how much I will pay for my dial-up
connection.
BB> bye, bolek
BB> Dne 6. červen 2003, <[rebol-list--rebol--com]> napsal:
>> Hello rebol-list,
>>
>> is there any simple way how to subtract 2 dates?
>> I had to write this function:
>>
>> subtract-dates: func[
>> "Returns the second date subtracted from the first in time! datatype."
>> end [date!] start [date!]
>> /local time days
>> ][
>> if end < start [return negate subtract-dates end start]
>> time: (either none? end/time [0:0][end/time]) - (either none? start/time [0:0][start/time])
>> either 0 < days: end/day - start/day [(days * 24:00) + time][ time ]
>> ]
>>
>> ;so for example this will return time since 1-1-2003:
>> subtract-dates now 1-1-2003
>>
>> --
>> Best regards,
>> rebOldes mailto:[rebol-list2--seznam--cz]
>>
>> --
>> To unsubscribe from this list, please send an email to
>> [rebol-request--rebol--com] with "unsubscribe" in the
>> subject, without the quotes.
>>
>>
BB> ______________________________________________________________________
BB> Reklama:
BB> Připrav se na nejpříšernější zážitek v životě na http://ad2.seznam.cz/redir.cgi?instance=46466%26url=http://www.priserky.cz
BB> --
BB> To unsubscribe from this list, please send an email to
BB> [rebol-request--rebol--com] with "unsubscribe" in the
BB> subject, without the quotes.
--
Best regards,
rebOldes mailto:[oliva--david--seznam--cz]