DateTime::Format::Strptime bug report

2010-09-02 Thread Matthew Hall
Hello all, I am trying to parse BSD Syslog format time stamps, like this one: Sep 1 05:39:02 Using the DateTime::Format::Strptime class, the call is failing with the following result, when I use the format string '%b %d %H:%M:%S'. There is no use providing a month name (Sep) without providing

Duration or elapsed time in days?

2010-09-02 Thread Gabor Szabo
Hi, I am probably missing something obvious but I could not yet figure out how can I get the number of days between two DateTime objects. So far the best I managed was $d1 = DateTime-new(...); $d2 = DateTime-new(...); my $sec = $d2-subtract_datetime_absolute($d1)-seconds; print $sec/60/60/24,

Re: Recurring DateTimes

2010-09-02 Thread Flavio S. Glock
Please take a look at the 'week_start_day' options: http://search.cpan.org/~fglock/DateTime-Event-Recurrence-0.16/lib/DateTime/Event/Recurrence.pm#The_%22week_start_day%22_Parameter The week_start_day represents how the 'first week' of a period is calculated: mo - this is the default. The first

Re: Duration or elapsed time in days?

2010-09-02 Thread Dave Rolsky
On Thu, 2 Sep 2010, Gabor Szabo wrote: $d1 = DateTime-new(...); $d2 = DateTime-new(...); my $sec = $d2-subtract_datetime_absolute($d1)-seconds; print $sec/60/60/24, \n; my $dur = $d1-delta_days($d2); print $dur-in_units('days'); -dave

RE: DateTime::Format::Strptime bug report

2010-09-02 Thread Metz, Bobby
You can add the current year to your string value prior to parsing. my $val = Sep 1 05:39:02; # Grab the year either via exec or via DateTime, your choice chomp(my $year = `date '+%Y'`); # --or-- my $year = strftime('%Y',localtime(time)); # Then combine and parse the string value into a DT

Re: DateTime::Format::Strptime bug report

2010-09-02 Thread Matthew Hall
It'd also be good to fix the bug where errors don't work if croak is disabled. Makes it real hard to do good automated processing of potentially bad input. On Thu, Sep 02, 2010 at 10:55:16AM -0700, Matthew Hall wrote: On Thu, Sep 02, 2010 at 01:24:03PM -0400, Metz, Bobby wrote: You can add

RE: DateTime::Format::Strptime bug report

2010-09-02 Thread Metz, Bobby
On Thu, Sep 02, 2010 at 01:24:03PM -0400, Metz, Bobby wrote: You can add the current year to your string value prior to parsing. Thanks. I'll adopt the DateTime based version in your second mail. You're welcome. Of course you could also alter you syslog config to include the year,

RE: DateTime::Format::Strptime bug report

2010-09-02 Thread Dave Rolsky
On Thu, 2 Sep 2010, Metz, Bobby wrote: -Original Message- From: Metz, Bobby # Grab the year either via exec or via DateTime, your choice chomp(my $year = `date '+%Y'`); # --or-- my $year = strftime('%Y',localtime(time)); My apologies, I said using DateTime above but I used a POSIX

Re: Duration or elapsed time in days?

2010-09-02 Thread Gabor Szabo
On Thu, Sep 2, 2010 at 7:01 PM, Dave Rolsky auta...@urth.org wrote: On Thu, 2 Sep 2010, Gabor Szabo wrote: $d1 = DateTime-new(...); $d2 = DateTime-new(...); my $sec = $d2-subtract_datetime_absolute($d1)-seconds; print $sec/60/60/24, \n;  my $dur = $d1-delta_days($d2);  print

Re: DateTime::Format::Strptime bug report

2010-09-02 Thread Matthew Hall
On Thu, Sep 02, 2010 at 01:51:42PM -0500, Dave Rolsky wrote: Or you could do the simple version ... DateTime-now()-year(); Good call. Implemented. -dave Matthew.