Time Function
[1/8] from: etcha::gsat::net::au at: 12-Dec-2000 5:10
Greets All,
Im trying to write a function that calculates time elapsed (eg compare 12/12/2000,6:30:00
to 17/01/2001,12:00:00) , ive done the basic conversion of date/time to hours/minutes/seconds
elapsed, but i cant figure out how to turn say "777:45:03" back into weeks / days /
hours / minutes / seconds elapsed.
help anyone?
etcha
[2/8] from: giovanni:cardona at: 11-Dec-2000 14:26
Im not a Rebol expert (Im just learning now)
but it seems that print (777:45:03 / 24:00:00) tells you the days
and print (777:45:03 / (24:00:00 * 7)) tells you the weeks.
I bet there's a simple line evualator for this, but I dont know :)
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
"Miracles happen only to those who believe in them."
* Visit 'The International Order of Sea-Monkey Owners' web site
* http://roads.to/seamonkey
* To subscribe to our monthly news, send a blank email to:
* [instantlife-subscribe--listbot--com]
----- Original Message -----
From: Aden Burnie <[etcha--gsat--net--au]>
To: <[rebol-list--rebol--com]>
Sent: Monday, December 11, 2000 10:10 AM
Subject: [REBOL] Time Function
> Greets All,
>
> Im trying to write a function that calculates time elapsed (eg compare
12/12/2000,6:30:00 to 17/01/2001,12:00:00) , ive done the basic conversion
of date/time to hours/minutes/seconds elapsed, but i cant figure out how to
turn say "777:45:03" back into weeks / days / hours / minutes / seconds
elapsed.
[3/8] from: rchristiansen:pop:isdfa:sei-it at: 11-Dec-2000 12:49
You could first convert your elapsed times into the time! datatype...
>> test-time: make time! 777:45:03
== 777:45:03
>> print test-time
777:45:03
Then you will at least have a datatype! object to work with, as such...
>> print test-time/hour
777
>> print test-time/minute
45
>> print test-time/second
3
You can then discover the number of days in decimal form...
>> test-days: test-time/hour / 24
== 32.375
Just some stuff to think about
-Ryan
[4/8] from: etcha:gsat:au at: 12-Dec-2000 5:59
That muched ive figured out so far, but want i want to do is convert
it into weeks / days / hours / minutes / seconds, something like
1 Week, 32 days, 10 Hours, 35 minutes and 23 seconds has elapsed
i cant figure out how to calcuate that offa the time value alone.
[5/8] from: rchristiansen:pop:isdfa:sei-it at: 11-Dec-2000 13:29
You could first convert your elapsed times into the time! datatype...
>> test-time: make time! 777:45:03
== 777:45:03
You can then discover the number of weeks or days in decimal form...
>> test-weeks: test-time/hour / 168
== 4.625
>> test-days: test-time/hour / 24
== 32.375
That's a start.
-Ryan
[6/8] from: kevin:sunshinecable at: 11-Dec-2000 11:47
On Tue, 12 Dec 2000, Aden Burnie wrote:
> Im trying to write a function that calculates time elapsed (eg
> compare 12/12/2000,6:30:00 to 17/01/2001,12:00:00) , ive done the basic
> conversion of date/time to hours/minutes/seconds elapsed, but i cant
> figure out how to turn say "777:45:03" back into weeks / days / hours /
> minutes / seconds elapsed.
How about something like this:
a: to-time "777:45:03"
weeks: to-integer a/hour / (24 * 7)
a: a/hour: a/hour - (weeks * 24 * 7)
days: to-integer a/hour / 24
a: a/hour: a/hour - (days * 24)
print rejoin ["Time elapsed: " weeks " weeks, " days " days, " a]
Regards,
Kev
[7/8] from: etcha:gsat:au at: 12-Dec-2000 7:20
thats calculating each one individually, nevermind though i figured it out,
i simply calculated the hours for how many days , took that away from total
hours , and added on the minutes and seconds, makes it easier also that i
can
now work with the full number of days for easy caclulating into weeks.
thanks to all , your comments helped to get my brain in gear.
[8/8] from: g:santilli:tiscalinet:it at: 12-Dec-2000 14:23
Aden Burnie wrote:
> That muched ive figured out so far, but want i want to do is convert
> it into weeks / days / hours / minutes / seconds, something like
> "1 Week, 32 days, 10 Hours, 35 minutes and 23 seconds has elapsed"
> i cant figure out how to calcuate that offa the time value alone.
Here's a hack that may help you out:
>> d: 1-Jan-2000
== 1-Jan-2000
>> d/time: 777:00:00
== 777:00
>> d
== 2-Feb-2000/9:00
Otherwise, what's the problem with:
>> days: 777 / 24
== 32.375
>> hours: 0.375 * 24
== 9
etc.?
HTH,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/