-
-
19 Aug 2014 10:44:16 UTC
- Distribution: MooX-Types-MooseLike-DateTime
- Module version: 0.01
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (2218 / 0 / 0)
- Kwalitee
Bus factor: 0- 100.00% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (9.34KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
MooX::Types::MooseLike::DateTime - a DateTime type for Moo
SYNOPSIS
package Person; use Moo; use DateTime; use MooX::Types::MooseLike::DateTime qw/DateAndTime/; has birthdate => ( isa => DateAndTime, is => 'ro', default => sub { DateTime->today } );
TYPES
DateAndTime
A DateTime object.
DateTime
A DateTime object. Exactly the same as the DateAndTime type. If using this type and the DateTime module in your package, you'll have to alias DateTime to something else.
package Person; use Moo; use MooX::Types::MooseLike::DateTime qw/DateTime/; use aliased 'DateTime' => 'DT'; has birthdate => ( isa => DateTime, is => 'ro', default => sub { DT->today } );
TIPS
- Coercion
-
use DateTime::Format::Strptime; use Scalar::Util qw/blessed/; has birthdate => ( isa => DateAndTime, is => 'ro', default => sub { DateTime->today }, coerce => sub { (blessed($_[0]) and (blessed($_[0]) eq 'DateTime')) ? $_[0] : DateTime::Format::Strptime->new(pattern => '%F %T')->parse_datetime($_[0]) } );
AUTHOR
Luke Triantafyllidis <ltriant@cpan.org>
REPOSITORY
https://github.com/ltriant/MooX-Types-MooseLike-DateTime
SEE ALSO
MooX::Types::MooseLike, DateTime
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install MooX::Types::MooseLike::DateTime, copy and paste the appropriate command in to your terminal.
cpanm MooX::Types::MooseLike::DateTime
perl -MCPAN -e shell install MooX::Types::MooseLike::DateTime
For more information on module installation, please visit the detailed CPAN module installation guide.