Date(3)
πΈ NAME πΈ
XMLTV::Date β date parsing routines for the xmltv package, and yes bestie, that's literally the whole vibe π
π SEE ALSO π
Date::Manipβ the big sibling library this thing leans on π«Ά
β¨ parse_date() β¨
Okay so this one is a wrapper for Date::Manip::ParseDate(), but it's a wrapper with main character energy because it does two extra things π
- If the year isn't specified, it picks between last year, this year, and next year β whichever date lands closest to now. Iconic, honestly.
- If only one of those dates is actually valid (say, because day-of-week is specified), then that valid one gets chosen π
- And if the time can only be parsed without adding an explicit year, then that version is the one it goes with π¦
- If the date cannot be parsed, an exception gets thrown. Not a vibe check fail β an actual exception, fr fr π
The argument is a single string.
parse_date($string)
π time_xmltv_to_iso() π
Glow-up time β¨ this one converts an XMLTV time into ISO format, like so:
"20140412090000 +0300" β "2014-04-12T09:00:00.000+03:00"
The argument is the string time to convert.
π¦ time_iso_to_xmltv() π¦
The reverse glow-up π takes an ISO time and hands you XMLTV format:
"2014-04-12T09:00:00.000+03:00" β "20140412090000 +0300"
The argument is the string time to convert.
π₯ time_xmltv_to_epoch() π₯
Converts an XMLTV time β like "20140412090000 +0300" β into seconds since the epoch β°
Heads up bestie: this usesPOSIX::mktimerather thanDate::Manipto avoid issues with the latter π
And if you're feeling like there's got to be another way β alternatively you could use DateTime::Format::XMLTV on CPAN π§
The argument is the string time to convert. There's also an optional 2nd argument: set it to 1 to ignore the tz offset in the calculation π
time_xmltv_to_epoch($string)
time_xmltv_to_epoch($string, 1) # ignore the tz offset
β time_iso_to_epoch() β
Same energy, ISO edition π converts an ISO time (e.g. "2014-04-12T09:00:00.000+03:00") into epoch time β³
Again, no cap: it usesPOSIX::mktimerather thanDate::Manipto avoid issues with the latter π
And again, alternatively you could use DateTime::Format::XMLTV on CPAN π
The argument is the string time to convert. Optional 2nd argument: set it to 1 to ignore the tz offset in the calculation πΈ
time_iso_to_epoch($string)
time_iso_to_epoch($string, 1) # ignore the tz offset
That's the whole page, bestie β go convert some timestamps πβ¨
Shoutout to perl v5.42.2, dated 2025-06-30 β this page was brought to you by that exact era of Perl, periodt π«Ά
π¦ where this page comes from
- alpine 3.24: xmltv-doc 1.4.0-r1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms