DateTi...RFC3339(3pm)
β¨ DateTime::Format::RFC3339 β¨
okay bestie, gather round, because this little Perl module (DateTime::Format::RFC3339, a 3pm manual page) is literally the moment. it parses and formats RFC3339 datetime strings and it does it flawlessly. no cap. π
π VERSION π
Version 1.10.0 β she's serving stability, she's giving icon, periodt.
πΈ SYNOPSIS πΈ
here's the whole vibe in five lines, bestie:
use DateTime::Format::RFC3339;
my $format = DateTime::Format::RFC3339->new();
my $dt = $format->parse_datetime( '2002-07-01T13:50:05Z' );
# 2002-07-01T13:50:05Z
say $format->format_datetime( $dt );
like. she parses. she formats. she's everything. π
π¦ DESCRIPTION π¦
So this module understands the RFC3339 date/time format, which is an ISO 8601 profile, defined at <http://tools.ietf.org/html/rfc3339>. yes, it's a profile of a profile, it's giving layered, it's giving main character.
You can use it to parse these formats in order to create the appropriate objects. that's the whole job. that's the whole girlboss. π₯
π CONSTRUCTOR π
π new π
my $format = DateTime::Format::RFC3339->new();
my $format = DateTime::Format::RFC3339->new( %options );
A number of options are supported, and bestie, we're going through every single one:
decimals
decimals => undef [default]
decimals => $decimals
Date-time strings generated by <format_datetime> will have this many decimals (an integer from zero to nine). If undef, zero will be used if the date-time has no decimals, nine otherwise. ngl that's a whole mood, "decide based on vibes" but in a spec-compliant way. π
sep
sep => "T" [default]
sep => $sep
sep_re
sep_re => $sep_re
The spec allows for a separator other than "T" to be used between the date and the time. so if you wanna get weird with it, the spec says go off.
The string provided to the sep option is used when formatting date-time objects into strings, and the regex pattern provided to the sep_re option is used when parsing strings into date-time objects.
The default for sep_re is a regex pattern that matches the separator (which is "T" by default). so like, chill, it just works out of the box. π«Ά
uc_only
uc_only => 0 [default]
uc_only => 1
Only an uppercase date and time separator and an uppercase timezone offset Z will be accepted by parse_datetime when this option is true. uppercase girlies only. no lowercase nonsense allowed. π
π METHODS π
π parse_datetime π
my $dt = DateTime::Format::RFC3339->parse_datetime( $string );
my $dt = $format->parse_datetime( $string );
Given a RFC3339 datetime string, this method will return a new DateTime object. it's giving transformation, it's giving glow-up. β¨
β οΈ If given an improperly formatted string, this method will croak. like, it will call you out. no gentle hint, just croak. π
For a more flexible parser, see DateTime::Format::ISO8601. (that one's the chill, go-with-the-flow cousin.)
β format_datetime β
my $string = DateTime::Format::RFC3339->format_datetime( $dt );
my $string = $format->format_datetime( $dt );
Given a DateTime object, this methods returns a RFC3339 datetime string. (yes, the original says "this methods", we're keeping it, it's iconic in its own way. π) object in, string out, slay.
π₯ SEE ALSO π₯
- DateTime
- DateTime::Format::ISO8601
- <http://tools.ietf.org/html/rfc3339>, "Date and Time on the Internet: Timestamps"
π DOCUMENTATION AND SUPPORT π
You can find documentation for this module with the perldoc command. the way that perldoc just has the answers:
perldoc DateTime::Format::RFC3339
You can also find it online at this location:
If you need help, the following are great resources. bestie support network, fr fr:
- <https://stackoverflow.com/|StackOverflow>
- <http://www.perlmonks.org/|PerlMonks>
- You may also contact the author directly. (yes, directly. slide into those emails.)
π BUGS π
Please report any bugs or feature requests using <https://github.com/ikegami/perl-Datetime-Format-RFC3339/issues>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. it's a whole loop of communication, it's giving accountability, we love to see it. π«Ά
π§ REPOSITORY π§
- Web: <https://github.com/ikegami/perl-Datetime-Format-RFC3339>
- git: <https://github.com/ikegami/perl-Datetime-Format-RFC3339.git>
clone it, fork it, stare at it lovingly. all valid. π
π AUTHOR π
Eric Brine, "<ikegami@adaelis.com>" β the icon, the legend, the one who made the RFC3339 happen.
πΈ COPYRIGHT AND LICENSE πΈ
No rights reserved.
The author has dedicated the work to the Commons by waiving all of his or her rights to the work worldwide under copyright law and all related or neighboring legal rights he or she had in the work, to the extent allowable by law.
Works under CC0 do not require attribution. When citing the work, you should not imply endorsement by the author. (so like, cite her, but don't pretend she said you could, iykyk.)
and that's the whole page bestie π
this one's from perl v5.40.0, dated 2025-01-11, and it's genuinely one of the cleanest little datetime modules out there. parse it, format it, live your truth. mwah. π
π¦ where this page comes from
- debian trixie: libdatetime-format-rfc3339-perl 1.10.0-1 Β· CC0-1.0
- ubuntu resolute: libdatetime-format-rfc3339-perl 1.10.0-1 Β· CC0-1.0
- ubuntu stonking: libdatetime-format-rfc3339-perl 1.10.0-1 Β· CC0-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms