Time(3pm)
π Lire::Time β the manual page, but make it make sense π
okay so this is Time(3pm) from LogReport's Lire documentation, and bestie, it's literally the glow-up your log-parsing era needed β¨
πΈ NAME πΈ
Lire::Time β parses and prints dates in formats common to many log files. that's it, that's the whole vibe. it reads dates, it writes dates, it's giving multilingual but for timestamps π«Ά
β¨ SYNOPSIS β¨
use Lire::Time qw/ syslog2cal /;
my @ltime = localtime;
while ( <LOGFILE> ) {
#...
my $time = syslog2cal( $m, $d, $t, \@ltime );
}
like, that's the whole group chat. import the one function you want, grab localtime, loop over your logfile, and syslog2cal does its little conversion moment π
π¦ DESCRIPTION π¦
okay so this module supplies many functions to parse dates in the formats you're likely to run into in log files β and ngl, log files are chaotic, so this is doing the lord's work π. it also offers many functions to format epoch time into a useful format, so you can go both directions. iconic.
π NOTE ABOUT FUNCTION EXPORT π
so like β altough all documented functions are exported by default to the caller namespace (yes, that's how the original spells it, "altough", we're not fixing it, we're respecting the ancestors π), you should explicitely import the functions you require. why? because exporting by default isn't recommanded by the perl modules guidelines. so like. do the polite thing. import what you need π
(i kept the original spellings of "altough", "explicitely", and "recommanded" because that's literally what the page says and i'm not out here editing people's history π«Ά)
π₯ DATE PARSING FUNCTIONS π₯
this module includes several functions that convert between a more human readable date format and UNIX epoch time. all parsing functions will return the number of seconds since Jan 1 1970 00:00:00 UTC and will die() when passed invalid arguments. so like, feed them garbage and they will throw hands π
β date2cal()
my $time = date2cal( $year, $month, $day, $time, [$timezone] );
my $time = date2cal( "2001 Mar 20 09:32:29 +0100" );
this function will convert a date in the date(1) default output format to UNIX epoch time. it accepts either the date in a string or splitted on whitespace β dealer's choice, both slay π
if the timezone component is omitted, the local timezone is assumed (usually based on the value of the TZ environment variable).
β syslog2cal()
my $time = syslog2cal( $month, $day, $time, $local_tm_ref );
my $time = syslog2cal( "Mar 11 13:21:00", $local_tm_ref );
this function will convert a date in the syslog default output format to UNIX epoch time. again, it accepts either the date in a string or splitted on whitespace β¨
since the syslog format doesn't contain timezone information, the local timezone is assumed (usually determined by the TZ environment variable). no cap, that's just how it is.
the last argument is a reference to an array returned by localtime():
my $local_tm_ref = [localtime()];
it is used to determine the year. so don't skip it, bestie, it's load-bearing π«Ά
β clf2cal()
my $time = clf2cal( "[18/Mar/2001:15:59:30 +0100]" );
this function will convert a date as found in Common Log Format to UNIX epoch time. brackets and all. she ate π
π DATE FORMATING FUNCTIONS π
(yes, "FORMATING", one T β that's the original, respect it π)
this module includes some functions to convert a date in UNIX epoch time to some more human readable output. all functions will die() when passed invalid arguments. same energy as the parsers, same consequences π
πΈ cal2rfc()
print cal2rfc( $time );
this function will convert a date in UNIX epoch time to the RFC822 format (used in email, for example). an RFC822 date looks like:
Wed, 30 May 2001 12:45:13 +0000
the timezone offset specification will correspond to the local timezone (usually determined by the TZ environment variable). very demure, very formatted π
πΈ cal2ymdhms()
print cal2ymdhms( $time );
this function converts a date in UNIX epoch time to a string of the form:
YYYYMMDDHHMMSS
this representation will correspond to the time in the local timezone (usually determined by the TZ environment variable.)
πΈ getMonthName()
print getMonthName( 0 ); # Gives 'Jan'
this function takes as parameter a number (0-11) representing the month (as returned by localtime() for example) and will return the English abbreviated name of that month ( Jan, Feb, etc. ). zero-indexed months, we love a classic π
π AUTHOR π
Joost van Baal <joostvb@logreport.org>
put some respect on the name π«Ά
π VERSION π
$Id: Time.pm,v 1.10 2006/07/23 13:16:30 vanbaal Exp $
β COPYRIGHT β
Copyright (C) 2000-2002 Stichting LogReport Foundation LogReport@LogReport.org
This file is part of Lire.
Lire is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html.
fr fr read the license, it's literally the whole point of the free software moment π
and that's the page, bestie π¦ this was Lire 2.1.1, dated 2025-09-28, filed under Time(3pm) β mwah, go parse some logs π
β¨π
π¦ where this page comes from
- arch rolling: lire 2.1.1-8 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms