From: Craig S. <csc...@ya...> - 2001-01-11 01:43:17
|
I use: sub time_add { my ($time_date) = @_; my $time2 = &my_str2time($time_date); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time2); $time_date = sprintf("%d:%02d", $hour, $min); return $time_date; } I can then do stuff like: $Save{setback_off} = time_add "$Save{wakeup_time} - 1:20"; -Craig --- Bruce Winter <br...@mi...> wrote: > > can someone show me some simple code to do calculations on time.. I want > > to do something like this > > > > my $time_length = $Time_Sunset-$Time_Sunrise+1:00; > > speak "The time will be $time_length"; > > > > I've tried using > > my $time_length = &time_diff($Time_Sunset,$Time_Sunrise); > > > > but I get a 2 for that one.. > > Looks like I need to document time_diff. It currently only accepts time in > seconds. > > If you are delaing with time strings (e.g. $Time_Sunset = '6:30 pm'), then > you first need to convert the time string to seconds using my_str2time. For > example: > > my $time_length = my_str2time $Time_Sunset - my_str2time > "$Time_Sunrise+1:00"; > > my_str2time supports simple +- time offsets, like in the above example. > > Bruce > > > ________________________________________________________ > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > __________________________________________________ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/ |