MooseX...SO8601(3pm)
π NAME
okay so bestie, MooseX::Types::ISO8601 is the vibe: it's a bundle of ISO8601 date and duration string type constraints, plus the coercions, for Moose. β¨ That's the whole manual page title, folded in right up top like a little name tag, because we're polite like that. π
β¨ VERSION
version 0.20 β yes, this is the one, periodt. π
πΈ SYNOPSIS
no because LOOK at this, it's giving chef's kiss π§
use MooseX::Types::ISO8601 qw/
ISO8601DateTimeStr
ISO8601TimeDurationStr
/;
has datetime => (
is => 'ro',
isa => ISO8601DateTimeStr,
);
has duration => (
is => 'ro',
isa => ISO8601TimeDurationStr,
coerce => 1,
);
Class->new( datetime => '2012-01-01T00:00:00' );
Class->new( duration => 60 ); # 60s => PT00H01M00S
Class->new( duration => DateTime::Duration->new(%args) )
like, that's it. that's the flex. π
π¦ DESCRIPTION
so basically this module packages up several TypeConstraints, coercions included, for when you're working with ISO8601 date strings and the whole DateTime suite of objects. it is exactly what it says on the tin, no cap. π
π DATE CONSTRAINTS
πΈ ISO8601DateStr
an ISO8601 date string, bestie. E.g. "2009-06-11". iconic. π
πΈ ISO8601TimeStr
an ISO8601 time string. E.g. "12:06:34Z". timezone and all, we love to see it. π
πΈ ISO8601DateTimeStr
an ISO8601 combined datetime string. E.g. "2009-06-11T12:06:34Z". date AND time, main character energy fr fr. π
πΈ ISO8601DateTimeTZStr
an ISO8601 combined datetime string with a fully specified timezone. E.g. "2009-06-11T12:06:34+00:00". π
πΈ ISO8601StrictDateStr
πΈ ISO8601StrictTimeStr
πΈ ISO8601StrictDateTimeStr
πΈ ISO8601StrictDateTimeTZStr
so these are all of the above, BUT β and this is the important part β on top of validating the strings against regular expressions, an attempt gets made to actually parse the data into a DateTime object. π΅οΈββοΈ this catches the sus cases like "2013-02-31" which look correct but do not correspond to real-world values (bestie, february does not have 31 days, i don't care how confident that string is). π
fair warning: this bears a computation penalty. you're paying for that extra correctness. πΈ
π« COERCIONS
the date types will coerce from:
"Num"β the number gets treated as a time in seconds since the unix epoch. β±οΈ"DateTime"β the duration represented as aDateTimeobject."Str"β non-expanded date and time string representations.
e.g.:-
20120113 => 2012-01-13 170500Z => 17:05:00Z
20120113T170500Z => 2012-01-13T17:05:00Z
representations of UTC time zone (only an offset of zero is supported)
e.g.:-
17:05:00+00:00 => 17:05:00Z 17:05:00+00 => 17:05:00Z 170500+0000
=> 17:05:00Z
2012-01-13T17:05:00+00:00 => 2012-01-13T17:05:00Z
2012-01-13T17:05:00+00 => 2012-01-13T17:05:00Z
20120113T170500+0000 => 2012-01-13T17:05:00Z
also (and honestly? we love a rebel π¦) it supports non-standards mixing of expanded and non-expanded representations
e.g.:-
2012-01-13T170500Z => 2012-01-13T17:05:00Z 20120113T17:05:00Z =>
2012-01-13T17:05:00Z
in addition, there are coercions from these string types to DateTime. π
β³ DURATION CONSTRAINTS
π ISO8601DateDurationStr
an ISO8601 date duration string. E.g. "P01Y01M01D". yes, it's a different M in a different spot, that's just ISO8601 being ISO8601. π
π ISO8601TimeDurationStr
an ISO8601 time duration string. E.g. "PT01H01M01S".
π ISO8601DateTimeDurationStr
an ISO8601 combined date and time duration string. E.g. "P01Y01M01DT01H01M01S". the whole package, lowkey. π
π« COERCIONS
the duration types will coerce from:
"Num"β the number gets treated as a time in seconds. β±οΈ"DateTime::Duration"β the duration represented as aDateTime::Durationobject.
the duration types will coerce to:
"Duration"β aDateTime::Duration, i.e. the"Duration"constraint fromMooseX::Types::DateTime. π«Ά
β¨ FEATURES
π¬ Fractional seconds
if provided, the number of seconds in time types is represented to microsecond accuracy. a full stop character is used as the decimal separator β which is allowed, but deprecated in preference to the comma character in ISO 8601:2004. so like, it works, but the comma is the moment. π
π LIMITATIONS
ngl, this module is probably full of bugs; patches are very welcome. please, we're begging, send patches. π
specifically, there are missing features:
- when no time-zone is specified, UTC is assumed. (should floating timezone be used?) π€
- no week number type
"Basic format", which lacks separator characters, is not supported for reading or writing.- tests are rubbish. π (their words, not mine, but okay periodt)
π SEE ALSO
MooseX::Types::DateTimeDateTimeDateTime::DurationDateTime::Format::ISO8601DateTime::Format::Duration<http://en.wikipedia.org/wiki/ISO_8601><http://dotat.at/tmp/ISO_8601-2004_E.pdf>
iykyk. πβ¨
π«Ά ACKNOWLEDGEMENTS
the development of this code was sponsored by my (Tom's) employer <http://www.state51.com/>. π shoutout to the employer, that's a real one.
π SUPPORT
bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-ISO8601> (or bug-MooseX-Types-ISO8601@rt.cpan.org <mailto:bug-MooseX-Types-ISO8601@rt.cpan.org>). π
there is also a mailing list available for users of this distribution, at <http://lists.perl.org/list/moose.html>. π¬
there is also an irc channel available for users of this distribution, at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>. come hang out, bestie! π
π AUTHORS
- Tomas Doran (t0m) <bobtfish@bobtfish.net>
- Dave Lambley <dlambley@cpan.org>
π CONTRIBUTORS
- Karen Etheridge <ether@cpan.org>
- Dave Lambley <dave@lambley.me.uk>
- zebardy <zebardy@gmail.com>
- Gregory Oschwald <goschwald@maxmind.com>
- Mark Fowler <mark@twoshortplanks.com>
π COPYRIGHT AND LICENCE
this software is copyright (c) 2009 by Tomas Doran. π
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so like, go off, respectfully. π
okay that's the whole thing! this page came from perl v5.36.0, dated 2022-10-16, and it lives in the MooseX::Types::ISO8601 section 3pm of your friendly neighbourhood user-contributed perl documentation. byeee, go coerce something cute ππβ¨
π¦ where this page comes from
- ubuntu noble: libmoosex-types-iso8601-perl 0.20-2 Β· Artistic-1.0-Perl OR GPL-1.0-only
- ubuntu resolute: libmoosex-types-iso8601-perl 0.20-2 Β· Artistic-1.0-Perl OR GPL-1.0-only
- ubuntu stonking: libmoosex-types-iso8601-perl 0.20-2 Β· Artistic-1.0-Perl OR GPL-1.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms