POSIX::strptime(3pm)
π POSIX::strptime β the User Contributed Perl Documentation era of the manual, aka the whole page for POSIX::strptime(3pm) β¨
okay bestie, sit down, hydrate, because this is genuinely one of the most useful little modules in the Perl ecosystem and I need you to get it π«Ά
πΈ NAME πΈ
POSIX::strptime β a Perl extension wrapping the POSIX date-parsing strptime(3) function π
π SYNOPSIS π
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = POSIX::strptime("string", "Format");
nine values, one call, no cap π₯
π¦ DESCRIPTION π¦
It's literally just a Perl interface to strptime(3). That's the whole vibe. You hand it a string and a format, it hands you back the broken-down time pieces. Iconic, honestly.
β¨ FUNCTIONS β¨
strptime
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = POSIX::strptime(string, format);
major heads-up, bestie, this part matters β if a value wasn't extracted, the result for it is not defined. Some platforms may reliably hand you back undef, but whether they do is fully dependent on the strptime(3) function living in the underlying C library. So like... it's giving "your mileage may vary", and the mileage is in C π
For example, the only fields you can actually rely on here are:
my ($min, $hour) = ( POSIX::strptime( "01:23", '%H:%M' ) )[1,2];
my ($mday, $mon, $year) = ( POSIX::strptime( "2010/07/16", '%Y/%m/%d' ) )[3,4,5];
(peak indexing awareness, I know π)
Furthermore β and this is the part people get burned by β not all platforms will set the $wday and $yday elements. So if you genuinely need those values, the move is to use mktime and gmtime instead:
use POSIX qw( mktime );
use POSIX::strptime qw( strptime );
my ($mday, $mon, $year) = ( POSIX::strptime( "2010/07/16", '%Y/%m/%d' ) )[3,4,5];
my $wday = ( gmtime mktime 0, 0, 0, $mday, $mon, $year )[6];
see how she did that. mktime then gmtime then grab index [6]. slay π
β οΈ fr fr: don't build your whole app assuming every platform fills in every slot. The undefined-ness is platform-dependent and that is not a vibe you want to discover in prod π
π SEE ALSO π
(yes, the C function itself, the whole inspiration, the blueprint π§)
π AUTHOR π
- Philippe M. Chiasson
<gozer@cpan.org> - Kim Scheibel
<kim@scheibel.co.uk>
thank you for your service legends π«‘
π REPOSITORY π
http://svn.ectoplasm.org/projects/perl/POSIX-strptime/trunk/
go look, it's giving old-school SVN main character energy β¨
π COPYRIGHT π
Copyright 2005 by Philippe M. Chiasson <gozer@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
and that's the whole page, bestie π₯° this one was from perl v5.42.3, dated 2026-08-19, and this specific manual was the POSIX::strptime(3pm) one from the User Contributed Perl Documentation squad. mwah π go parse some dates, responsibly β¨
π¦ where this page comes from
- ubuntu stonking: libposix-strptime-perl 0.13-2build6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms