MooseX::Types::Date::Piece - Date::Piece type and coercions for Moose.
package Foo; use Moose; use MooseX::Types::Date::Piece qw( Date Duration ); has 'date' => ( is => 'ro', isa => Date, coerce => 1, ); has 'duration' => ( is => 'ro', isa => Duration, coerce => 1, ); # ... my $f = Foo->new( date => '2012-07-09', duration => '1day', );
The following type constants provided by MooseX::Types must be explicitly imported. The full class name may also be used (as strings with quotes) without importing the constant declarations.
A class type for Date::Piece.
Uses "date" in Date::Piece, where the string is formatted as
Uses "date" in Date::Piece, where the array is formatted as
[2012, 12, 31].
An exception is thrown if the value to be coerced is not in a valid format or if the date is invalid.
A class type for
Date::Piece::Duration. Subtypes include
year_unit. These objects are normally created using the
years constants and may be multiplied by an integer. They may also be used for date math by adding (or subtracting) them to
Date::Piece objects. See "Year-Month-and-etc-units" in Date::Piece for more information.
<stevenl at cpan.org>
Copyright © 2012 Steven Lee. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.