#5 better year guessing

open
nobody
None
5
2006-04-17
2006-04-17
Anonymous
No

Hi,
this code guesses the right year better than the old.
It assumes the year has changed if the current month is
before June and the month of the log entry is after June.

------------------

#year is not in syslog date format... try to guess it
from the local time
my($year);
my($cur_month);

(undef,undef,undef,undef,$cur_month,$year,undef,undef,undef)
= localtime(time);
$year += 1900;

#extract Date
my $month = $m{shift(@entry_split)};
if ($cur_month < 6 && $month > 6) { $year--; }
#yearchange since entry

$entry{'date'}="$year-".$month."-".shift(@entry_split)."
".shift(@entry_split);

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks