MooseX:...ntained(3)

πŸ“¦
version 0.16 Β· 2 versions
, in fedora 43

πŸ¦‹ MooseX::Types::DateTime::ButMaintained πŸ¦‹

okay bestie, so this is the User Contributed Perl Documentation page (section 3, iykyk) for MooseX::Types::DateTime::ButMaintained β€” the module that gives you DateTime-related constraints and coercions for Moose. it's giving ✨time math✨ and it's lowkey a whole saga (see DESCRIPTION, there's lore, there's drama, there's a fork). grab a boba and let's go πŸ’…


✨ NAME ✨

MooseX::Types::DateTime::ButMaintained β€” DateTime related constraints and coercions for Moose. that's the whole thing, that's the thesis πŸŽ€


🌸 SYNOPSIS 🌸

🫢 Export Example

you just pull in what you need by name and vibe check it:

use MooseX::Types::DateTime::ButMaintained qw(TimeZone);
has time_zone => (
                isa  => TimeZone
                , is => "rw"
                , coerce => 1
);
Class->new( time_zone => "Africa/Timbuktu" );
Class->new( time_zone => "CEST" );

🫢 Namespaced Example

or you go full namespace main-character mode and just use the module:

use MooseX::Types::DateTime::ButMaintained;
has time_zone => (
        isa  => 'DateTime::TimeZone'
        , is => "rw"
        , coerce => 1
);
Class->new( time_zone => "Africa/Timbuktu" );

πŸ’… CONSTRAINTS πŸ’…

these are the type constraints, and every single one of them comes with coercions, no cap πŸ”₯

πŸ‘‘ DateTime

a class type for DateTime.

  • from Num β€” uses from_epoch in DateTime. Floating values will be used for subsecond percision, see DateTime for details. πŸ•
  • from HashRef β€” calls new in DateTime with the hash entries as arguments.

πŸ‘‘ Duration

a class type for DateTime::Duration.

  • from Num β€” uses new in DateTime::Duration and passes the number as the seconds argument.
bestie, WARNING: due to leap seconds, DST changes etc this may not do what you expect. For instance passing in 86400 is not always equivalent to one day, although there are that many seconds in a day. See "How Date Math is Done" in DateTime for more details. πŸ’€ time is fake and the calendar is lying to you.
  • from HashRef β€” calls new in DateTime::Duration with the hash entries as arguments.

πŸ‘‘ 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 to load in DateTime::Locale. 🌈
  • from Locale::Maktext β€” the Locale::Maketext/language_tag attribute will be used with load in DateTime::Locale.

πŸ‘‘ DateTime::TimeZone

a class type for DateTime::TimeZone. this now as of 0.05 coerces from non-globally ambigious Olson abbreviations, using Olson::Abbreviations. this won't work for abbreviations like "EST" which are only unambigious if you know the locale. it will coerce from abbreviations like "CEST" though. slay 🌍

  • from Str β€” treated as a time zone name or offset. See "USAGE" in DateTime::TimeZone for more details on the allowed values.

delegates to new in DateTime::TimeZone with the string as the name argument.


🧚 SEE ALSO 🧚

go read these too, they're iconic:

  • MooseX::Types::DateTimeX
  • DateTime

πŸ’œ AUTHOR πŸ’œ

Modern

Evan Carroll <me+cpan@evancarroll.com>

Yesteryear

Yuval Kogman <nothingmuch@woobling.org>

John Napiorkowski <jjn1056 at yahoo.com>


πŸ“ DESCRIPTION πŸ“

okay so this module packages several Moose::Util::TypeConstraints with coercions, designed to work with the DateTime suite of objects. cute, useful, obsessed 🫢

now for the lore, because this module has history and the original doc says it out loud: this module started as a fork of MooseX::Types::DateTime. the history and explaination goes like this β€” In Janurary 2009, I began a project to bring DateTime::Format::* stuff up to date with Moose. I created a framework that would greatly eliminate redundant code named DateTimeX::Format. this project's adoption was slowed by then (and still currently) bundeled package MooseX::Types::DateTime. MooseX::Types::DateTime was a badly packaged extention of two modules: the self-titled MooseX::Types::DateTime, and another random module MooseX::Types::DateTimeX. In Februrary of the same year, I repackaged the module MooseX::Types::DateTimeX with the authors blessing into a new package, for the purpose of removing its dependenices β€” namely Date::Manip β€” from MooseX::Types::DateTime.

unfortunately, this just added confusion. now, as of the time of writing, MooseX::Types::DateTimeX is available as a package, and it is available as a module which will be installed by MooseX::Types::DateTime. the benefit of removing the dependency on MooseX::Types::DateTime was never realized, and the patch that updates the dependencies, and the build system, remains in rt still as of writing. 😭 not the rt ticket still open.

so what IS this module, fr fr? this module is just the MooseX::Types::DateTime without the requirement on DateTimeX::Easy (which requires DateTime::Manip). and as of 0.05 this module supports globally unique Olson abbreviations, and dies when they are not globally unique. it does not play, it does not negotiate πŸ’€


Copyright (c) 2008 Yuval Kogman. All rights reserved
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.

Modifications (c) 2009 Evan Carroll. All rights reserved
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.

and that's the page bestie!! πŸ’– this doc was rendered by perl v5.42.0 on 2025-07-25, and that's the whole vibe check β€” go forth and coerce your timestamps responsibly. periodt πŸŽ€βœ¨

πŸ“¦ where this page comes from