Time elapsed since... - 06/10/05 09:57 AM
Alright, since my brain doesn't seem to be functioning tonight, I've been struggling with a script.
This script *should* tell me how many years/months/days/hours/minutes has passed since <x> time.
I can do this, but not reliably.
ie:
/elapsed_time October 6th 2004 05:00:00am October 6th 2005 05:00:00pm
would return: Days: 365, Hours: 12, Minutes: 0, Seconds: 0
Now.. the problem would be doing months->years, as the days in months vary, so I wouldn't be able to do: var %months = $calc( %days / 30 )
So, does anyone know of any other way I could figure out how many months have passed?
This script *should* tell me how many years/months/days/hours/minutes has passed since <x> time.
I can do this, but not reliably.
Code:
alias elapsed_time { var %otime = $ctime($1-4) , %ntime = $ctime($5-8) var %seconds = $calc( %ntime - %otime ) var %minutes = $calc( %seconds / 60 ) var %hours = $calc( %minutes / 60 ) var %days = $calc( %hours / 24 ) var %lohours = $calc( %hours % 24 ) var %lomins = $calc( %minutes % 60 ) var %losecs = $calc( %seconds % 60 ) echo -stg Days: $int(%days) $+ , Hours: $int(%lohours) $+ , Minutes: $int(%lomins) $+ , Seconds: $int(%losecs) }
ie:
/elapsed_time October 6th 2004 05:00:00am October 6th 2005 05:00:00pm
would return: Days: 365, Hours: 12, Minutes: 0, Seconds: 0
Now.. the problem would be doing months->years, as the days in months vary, so I wouldn't be able to do: var %months = $calc( %days / 30 )
So, does anyone know of any other way I could figure out how many months have passed?