MooseX:...teTimeX(3)
โจ MooseX::Types::DateTimeX โจ
okay bestie, so this is a page from the User Contributed Perl Documentation section of the manual, and it's all about MooseX::Types::DateTimeX ๐ โ the type library that's literally just out here giving you DateTime types with extra coercions because we deserve nice things ๐
๐ธ NAME ๐ธ
MooseX::Types::DateTimeX โ it's extensions to MooseX::Types::DateTime::ButMaintained, no cap ๐
๐ฆ SYNOPSIS ๐ฆ
okay so here's the whole vibe in code form, look at her:
package MyApp::MyClass;
use MooseX::Types::DateTimeX qw( DateTime );
has created => (
isa => DateTime,
is => "rw",
coerce => 1,
);
my $instance = MyApp::MyClass->new(created=>'January 1, 1980');
print $instance->created->year; # is 1980
## Coercions from the base type continue to work as normal.
my $instance = MyApp::MyClass->new(created=>{year=>2000,month=>1,day=>10});
and like, if you want more example usage (and honestly who doesn't ๐ซถ), please see the test case. it's right there. go look. it ate.
๐ DESCRIPTION ๐
so this module builds on MooseX::Types::DateTime to add extra custom types and coercions. and because it's building on a type that already exists, all the coercions and constraints are inherited โ you get the whole family, not just the new babies. periodt โจ
and yeah, the package name is left as is for legacy reasons ๐ โ this module is really a Type with coercions for DateTimeX::Easy. DateTimeX is just a namespace for the non-core / less-official DateTime modules, iykyk.
๐ SUBTYPES ๐
this module defines the following additional subtypes, bestie. two of them. both iconic.
โญ DateTime โญ
it's a Subtype of DateTime, and the glow-up is that it adds an additional coercion from strings ๐
it uses DateTimeX::Easy to try and convert strings โ like, strings such as "yesterday" โ into a valid DateTime object. and here's the thing, lowkey important: because of ambiguity with how different systems might localize their timezone, string parsing may not always return the most expected value. in general it tries to localize to UTC whenever possible. feedback welcomed! ๐
๐ง Duration ๐ง
a Subtype of DateTime::Duration that coerces from a string. to attempt this, it uses the module Time::Duration::Parse. slay.
๐ CAVEATS ๐
okay so first of all, real talk: this module uses DateTimeX::Easy, which is way more DWIM than any sane person would desire ๐ญ. like, way too much. DateTimeX::Easy works by falling back until something makes sense โ and that is variable. not deterministic. variable. ๐
furthermore, all the modules that DateTimeX::Easy can use aren't required for "proper" function of DateTimeX::Easy. so what does this mean? simple: your mileage may vary in your coercions, because DateTimeX::Easy is installation specific. it's giving chaos, honestly. ๐ซ
๐ SEE ALSO ๐
MooseX::Types::DateTime::ButMaintainedโ the replacement for this module, with coercions that come with less voodoo ๐ฎDateTimeX::Easyโ the backend of this module
๐ AUTHOR ๐
John Napiorkowski <jjn1056 at yahoo.com>
Broken into a seperate package from MooseX::Types::DateTime by Evan Carroll.
๐ LICENSE ๐
Copyright (c) 2008 John Napiorkowski.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie ๐ this doc was generated by perl v5.42.0 on 2025-07-25, and it's the MooseX:...teTimeX(3) manual page โ thanks for reading, you're the main character, go coerce some dates responsibly ๐โจ๐
๐ฆ where this page comes from
- fedora 43: perl-MooseX-Types-DateTimeX 0.10-46.fc43 ยท GPL-1.0-or-later OR Artistic-1.0-Perl
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms