MooseX...ateTime(3pm)
π MooseX::Types::DateTime π
okay so bestie, this is the MooseX::Types::DateTime page β (3pm) energy, straight outta the User Contributed Perl Documentation section. Pull up a chair, we're doing DateTime types together π«Ά
β¨ NAME β¨
MooseX::Types::DateTime β DateTime related constraints and coercions for Moose. that's it, that's the whole vibe π
π VERSION π
version 0.14 β yeah she's on 0.14, and she's iconic for it β¨
π SYNOPSIS π
Export Example β when you just wanna pull the type in by name:
use MooseX::Types::DateTime qw(TimeZone);
has time_zone => (
isa => TimeZone,
is => "rw",
coerce => 1,
);
Class->new( time_zone => "Africa/Timbuktu" );
like, that's literally it. Africa/Timbuktu goes in, a whole time zone comes out. no cap π¦
π§ DESCRIPTION π§
So the tea is: this module packages several Moose::Util::TypeConstraints with coercions, and the whole point of them is to play nice with the DateTime suite of objects. that's the main character premise, periodt.
Namespaced Example β same idea, but you're not exporting anything and you just write the class name out in full:
use MooseX::Types::DateTime;
has time_zone => (
isa => 'DateTime::TimeZone',
is => "rw",
coerce => 1,
);
Class->new( time_zone => "Africa/Timbuktu" );
see how it just slaps? both ways work, pick your fighter π
π CONSTRAINTS π
literally the whole point of this page, bestie. this is where the type constraints live.
π DateTime
A class type for DateTime.
- from
Numβ Usesfrom_epochinDateTime. Floating values will be used for sub-second precision, seeDateTimefor details. yes, you read that right, floats are getting you sub-second precision, she's fancy like that β - from
HashRefβ CallsnewinDateTimewith the hash entries as arguments. cute, direct, no notes.
π Duration
A class type for DateTime::Duration.
- from
Numβ UsesnewinDateTime::Durationand passes the number as thesecondsargument.
π okay listen up because this one bites people: due to leap seconds, DST changes etc this may not do what you expect. For instance passing in86400is not always equivalent to one day, although there are that many seconds in a day. See "How Date Math is Done" inDateTimefor more details. fr fr, don't get got by the clocks, they're lowkey shady.
- from
HashRefβ CallsnewinDateTime::Durationwith the hash entries as arguments. this one's the safe cozy path π
πΈ DateTime::Locale
A class type for DateTime::Locale::root with the name DateTime::Locale.
- from
Strβ The string is treated as a language tag (e.g."en"or"he_IL") and given toloadinDateTime::Locale. it's giving very international of you βοΈ - from
Locale::Maktextβ TheLocale::Maketext/language_tagattribute will be used withloadinDateTime::Locale. (yes bestie, that spelling is exactly what the docs say, we do not fix, we report π«‘)
π¦ DateTime::TimeZone
A class type for DateTime::TimeZone.
- from
Strβ Treated as a time zone name or offset. See "USAGE" inDateTime::TimeZonefor more details on the allowed values.
Delegates to new in DateTime::TimeZone with the string as the name argument.
so "Africa/Timbuktu" comes in as a string and gets handed straight to new as name. delegated, done, slayed π
π SEE ALSO π
go read these too, they're the friends of the family:
MooseX::Types::DateTime::MoreCoercionsDateTime,DateTimeX::Easy
π«Ά GIVING THANKS π«Ά
If you found this module to be useful, please show your appreciation by:
- adding a
+1in MetaCPAN athttps://metacpan.org/dist/MooseX-Types-DateTime - and a star in GitHub at
https://github.com/moose/MooseX-Types-DateTime
seriously, a lil +1 and a star? that's it. that's the whole ask. it fuels us π₯Ήβ¨
π¬ SUPPORT π¬
Bugs may be submitted through the RT bug tracker at https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-DateTime (or bug-MooseX-Types-DateTime@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 say hi in #moose, the group chat is always open π«Ά
π§ AUTHOR π§
ΧΧΧΧ Χ§ΧΧ'ΧΧ (Yuval Kogman) nothingmuch@woobling.org
β CONTRIBUTORS β
- Karen Etheridge
ether@cpan.org - Dagfinn Ilmari MannsΓ₯ker
ilmari@ilmari.org - Florian Ragwitz
rafl@debian.org - John Napiorkowski
jjnapiork@cpan.org - Dave Rolsky
autarch@urth.org - Shawn M Moore
sartak@gmail.com
these are the icons who helped build the house, show respect π
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2008 by ΧΧΧΧ Χ§ΧΧ'ΧΧ (Yuval Kogman).
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the page bestie π generated for perl v5.40.1, dated 2026-01-18, under the MooseX...ateTime(3pm) manual name β go forth, coerce some time zones, and remember: floats for sub-second precision, and 86400 seconds is not always a day. ππβ¨
π¦ where this page comes from
- ubuntu resolute: libmoosex-types-datetime-perl 0.14-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-types-datetime-perl 0.14-1 Β· 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