MooseX:...teTimeX(3)

๐Ÿ“ฆ
version 0.10 ยท 2 versions
, in fedora 43

โœจ 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