Date value testing

T

Thos

I'm trying to corelate log files from various applications.
Unfortunately, the date format used in the log files differs from file
to file (e.g., Dec 1, 05 - December 01, 2005 - 01/12/05 - 01/12/2005).

I'm looking for some way to do something like

dategrep 01/12/2005 *.log

and have it return all the records with that date regardles of the date
format used in the file.

I'd also like to be able to do comparisons (e.g., if ( datefix(date1)
== datefix(date2))

Any suggestions.... does something like this exist?
 
S

Sherm Pendley

Thos said:
I'm trying to corelate log files from various applications.
Unfortunately, the date format used in the log files differs from file
to file (e.g., Dec 1, 05 - December 01, 2005 - 01/12/05 - 01/12/2005).

You might want to have a look at the Date::Manip module on CPAN.

sherm--
 
U

usenet

Thos said:
I'm trying to corelate log files from various applications.
Unfortunately, the date format used in the log files differs from file
to file (e.g., Dec 1, 05 - December 01, 2005 - 01/12/05 - 01/12/2005).

Warning - You're using non-US style dates (ie, 01/12 is December 1, not
January 12), so you need to be sure and tell Date::Manip about this
(with the Date_Init routine) - otherwise, US date format would be
assumed by the module:

#!//usr/bin/perl
use warnings; use strict;

use Date::Manip;
&Date_Init("DateFormat=non-US");

while (<DATA>) {
print ParseDate($_) ."\n";
}

__DATA__
Dec 1, 05
December 01, 2005
01/12/05
01/12/2005

-------- OUTPUT -----------------------
2005120100:00:00
2005120100:00:00
2005120100:00:00
2005120100:00:00

These are strings, BTW - compare with 'eq', not '=='
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,501
Latest member
Ledmyplace

Latest Threads

Top