Re: Rounding Date/Time

2011-05-06 Thread Peter Scott
On Mon, 02 May 2011 11:46:42 -0500, Matt wrote: > Have a date: > > 2011-05-02-16:40:51 [...] > > I need to round it to nearest 5 minute point. > > 2011-05-02-16:40:51 If you care about things like daylight savings time adjustments, calendar changes, or leap seconds, the answer requires consid

Re: Rounding Date/Time

2011-05-05 Thread Pete Smith
On May 2, 9:46 am, lm7...@gmail.com (Matt) wrote: Have a date: 2011-05-02-16:40:51 Using this to get it: $tm = gmtime; $time_stamp = sprintf "%04d-%02d-%02d-%02d:%02d:%02d", $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec; print "$time_stamp\n"; I need to r

Re: Rounding Date/Time

2011-05-04 Thread Rob Dixon
On 04/05/2011 18:14, C.DeRykus wrote: On May 3, 4:12 pm, rob.di...@gmx.com (Rob Dixon) wrote: On 03/05/2011 19:49, C.DeRykus wrote: use Time::localtime; use List::Util qw/reduce/; my @rounded_5mins = grep { not $_ % 5 } 0..60; my $curr_min = localtime->min; my $round_min = reduce { $curr_mi

Re: Rounding Date/Time

2011-05-04 Thread C.DeRykus
On May 3, 4:12 pm, rob.di...@gmx.com (Rob Dixon) wrote: > On 03/05/2011 19:49, C.DeRykus wrote: > > > > > > > > > > > On May 2, 9:46 am, lm7...@gmail.com (Matt) wrote: > >> Have a date: > > >> 2011-05-02-16:40:51 > > >> Using this to get it: > > >> $tm = gmtime; > >> $time_stamp = sprintf "%04d-%02

Re: Rounding Date/Time

2011-05-03 Thread Rob Dixon
On 03/05/2011 19:49, C.DeRykus wrote: On May 2, 9:46 am, lm7...@gmail.com (Matt) wrote: Have a date: 2011-05-02-16:40:51 Using this to get it: $tm = gmtime; $time_stamp = sprintf "%04d-%02d-%02d-%02d:%02d:%02d", $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec; print

Re: Rounding Date/Time

2011-05-03 Thread C.DeRykus
On May 3, 11:54 am, shawnhco...@ncf.ca (Shawn H Corey) wrote: > On 11-05-03 02:49 PM, C.DeRykus wrote: > > > my @rounded_5mins = grep { not $_ % 5 } 0..60; > > my @rounded_5mins = map { $_ * 5 } 0..12; > > # TIMTOWTDI > Make that: TIMTOWTDI++ # a much better way to do it -- Charles DeRykus -

Re: Rounding Date/Time

2011-05-03 Thread Shawn H Corey
On 11-05-03 02:49 PM, C.DeRykus wrote: my @rounded_5mins = grep { not $_ % 5 } 0..60; my @rounded_5mins = map { $_ * 5 } 0..12; # TIMTOWTDI -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and commu

Re: Rounding Date/Time

2011-05-03 Thread C.DeRykus
On May 2, 9:46 am, lm7...@gmail.com (Matt) wrote: > Have a date: > > 2011-05-02-16:40:51 > > Using this to get it: > > $tm = gmtime; > $time_stamp = sprintf "%04d-%02d-%02d-%02d:%02d:%02d", >  $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec; > print "$time_stamp\n"; > > I n

Re: Rounding Date/Time

2011-05-03 Thread Rob Dixon
On 02/05/2011 17:46, Matt wrote: Have a date: 2011-05-02-16:40:51 Using this to get it: $tm = gmtime; $time_stamp = sprintf "%04d-%02d-%02d-%02d:%02d:%02d", $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec; print "$time_stamp\n"; I need to round it to nearest 5 minut

Re: Rounding Date/Time

2011-05-02 Thread Jim Gibson
On 5/2/11 Mon May 2, 2011 9:46 AM, "Matt" scribbled: > Have a date: > > 2011-05-02-16:40:51 > > Using this to get it: > > $tm = gmtime; > $time_stamp = sprintf "%04d-%02d-%02d-%02d:%02d:%02d", > $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec; > print "$time_stamp\n

Re: Rounding Date/Time

2011-05-02 Thread Uri Guttman
> "M" == Matt writes: M> Have a date: M> 2011-05-02-16:40:51 M> Using this to get it: M> $tm = gmtime; M> $time_stamp = sprintf "%04d-%02d-%02d-%02d:%02d:%02d", M> $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec; M> print "$time_stamp\n"; use POSIX

Rounding Date/Time

2011-05-02 Thread Matt
Have a date: 2011-05-02-16:40:51 Using this to get it: $tm = gmtime; $time_stamp = sprintf "%04d-%02d-%02d-%02d:%02d:%02d", $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec; print "$time_stamp\n"; I need to round it to nearest 5 minute point. 2011-05-02-16:40:51 needs