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
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,
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
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
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
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
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,
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
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
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.
10 matches
Mail list logo