MooseX::Types::DateTime - DateTime related constraints and coercions for Moose
Export Example:
use MooseX::Types::DateTime qw(TimeZone); has time_zone => ( isa => TimeZone, is => "rw", coerce => 1, ); Class->new( time_zone => "Africa/Timbuktu" );
Namespaced Example:
use MooseX::Types::DateTime; has time_zone => ( isa => 'DateTime::TimeZone', is => "rw", coerce => 1, ); Class->new( time_zone => "Africa/Timbuktu" );
This module packages several Moose::Util::TypeConstraints with coercions, designed to work with the DateTime suite of objects.
A class type for DateTime.
Num
Uses "from_epoch" in DateTime. Floating values will be used for subsecond percision, see DateTime for details.
HashRef
Calls "new" in DateTime with the hash entries as arguments.
A class type for DateTime::Duration
Uses "new" in DateTime::Duration and passes the number as the seconds argument.
seconds
Note that 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.
86400
Calls "new" in DateTime::Duration with the hash entries as arguments.
A class type for DateTime::Locale::root with the name DateTime::Locale.
Str
The string is treated as a language tag (e.g. en or he_IL) and given to "load" in DateTime::Locale.
en
he_IL
The Locale::Maketext/language_tag attribute will be used with "load" in DateTime::Locale.
Locale::Maketext/language_tag
A class type for DateTime::TimeZone.
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.
name
MooseX::Types::DateTimeX
DateTime, DateTimeX::Easy
This module is maintained using git. You can get the latest version from git://github.com/nothingmuch/moosex-types-datetime.git.
Yuval Kogman <nothingmuch@woobling.org>
John Napiorkowski <jjn1056 at yahoo.com>
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.
To install MooseX::Types::DateTime, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Types::DateTime
CPAN shell
perl -MCPAN -e shell install MooseX::Types::DateTime
For more information on module installation, please visit the detailed CPAN module installation guide.