Date(3pm)
π NAME π
okay bestie, gather round, because this is XMLTV::Date β date parsing routines for the xmltv package β¨ It's a Perl module (that's the 3pm situation, iykyk), and it is so handy if you're out here wrangling dates from XMLTV files and you're tired of crying about it.
π SEE ALSO π
Date::Manipβ the icon this whole thing is built on top of π«Ά
π
parse_date() π
This one is a wrapper for Date::Manip::ParseDate() that does two extra things, and honestly? iconic behaviour.
- if the year is not specified, it picks between last year, this year and next year based on which date would be closest to now. and like, if only one of those dates is valid β say because day-of-week is specified β then the valid one gets chosen, no drama. and if the time can only be parsed without adding an explicit year, then that's the one it goes with. it just knows. π«
- an exception is thrown if the date cannot be parsed. no silent fails, no weird vibes, it WILL let you know π
Argument is a single string. that's it, that's the whole ask.
πΈ time_xmltv_to_iso() πΈ
Converts a XMLTV time to ISO format, like a lil glow-up for your timestamps:
- from:
20140412090000 +0300 - to:
2014-04-12T09:00:00.000+03:00
Argument is string time to convert. slay.
π¦ time_iso_to_xmltv() π¦
the reverse glow-up, bestie. converts an ISO time to XMLTV format:
- from:
2014-04-12T09:00:00.000+03:00 - to:
20140412090000 +0300
Argument is string time to convert.
β time_xmltv_to_epoch() β
Converts a XMLTV time to seconds since the epoch:
- from:
20140412090000 +0300
ngl this one usesPOSIX::mktimerather thanDate::Manipon purpose β to avoid issues with the latter. the drama was real, so we went around it π
alternatively you could use DateTime::Format::XMLTV on CPAN, if that's more your vibe.
Argument is string time to convert. Optional 2nd argument: set to 1 to ignore the tz offset in the calculation. π
π time_iso_to_epoch() π
Converts an iso time to epoch time:
- from:
2014-04-12T09:00:00.000+03:00
same energy as above: usesPOSIX::mktimerather thanDate::Manipto avoid issues with the latter π«
and again, alternatively you could use DateTime::Format::XMLTV on CPAN.
Argument is string time to convert. Optional 2nd argument: set to 1 to ignore the tz offset in the calculation.
okay that's the whole page, you're officially educated π§ this was documented for perl v5.40.1, dated 2025-04-19 β go forth and parse some dates, bestie, you've got this ππ
π¦ where this page comes from
- debian trixie: libxmltv-perl 1.4.0-1 Β· GPL-2.0-only
- ubuntu resolute: libxmltv-perl 1.4.0-1 Β· GPL-2.0-only
- ubuntu stonking: libxmltv-perl 1.4.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms