MooseX::Types::ISO8601 - ISO8601 date and duration string type constraints and coercions for Moose


MooseX-Types-ISO8601 documentation  | view source Contained in the MooseX-Types-ISO8601 distribution.

Index


NAME

Top

MooseX::Types::ISO8601 - ISO8601 date and duration string type constraints and coercions for Moose

SYNOPSIS

Top

    use MooseX::Types::ISO8601 qw/
        ISO8601TimeDurationStr
    /;

    has duration => (
        isa => ISO8601TimeDurationStr,
        is => 'ro',
        coerce => 1,
    );

    Class->new( duration => 60 ); # 60s => PT00H01M00S
    Class->new( duration => DateTime::Duration->new(%args) )

DESCRIPTION

Top

This module packages several TypeConstraints with coercions for working with ISO8601 date strings and the DateTime suite of objects.

DATE CONSTRAINTS

Top

ISO8601DateStr

An ISO8601 date string. E.g. 2009-06-11

ISO8601TimeStr

An ISO8601 time string. E.g. 12:06:34Z

ISO8601DateTimeStr

An ISO8601 combined datetime string. E.g. 2009-06-11T12:06:34Z

COERCIONS

The date types will coerce from:

Num

The number is treated as a time in seconds since the unix epoch

DateTime

The duration represented as a DateTime object.

DURATION CONSTRAINTS

Top

ISO8601DateDurationStr

An ISO8601 date duration string. E.g. P01Y01M01D

ISO8601TimeDurationStr

An ISO8601 time duration string. E.g. PT01H01M01S

ISO8601DateTimeDurationStr

An ISO8601 comboined date and time duration string. E.g. P01Y01M01DT01H01M01S

COERCIONS

The duration types will coerce from:

Num

The number is treated as a time in seconds

DateTime::Duration

The duration represented as a DateTime::Duration object.

The duration types will coerce to:

Duration

A DateTime::Duration, i.e. the Duration constraint from MooseX::Types::DateTime.

SEE ALSO

Top

VERSION CONTROL

Top

    http://github.com/bobtfish/moosex-types-iso8601/tree/master

Patches are welcome.

SEE ALSO

Top

BUGS

Top

Probably full of them, patches are very welcome.

Specifically missing features:

No timezone support - all times are assumed UTC
No week number type
Tests are rubbish.

AUTHOR

Top

Tomas Doran (t0m) <bobtfish@bobtfish.net>

The development of this code was sponsored by my employer http://www.state51.co.uk.

COPYRIGHT

Top


MooseX-Types-ISO8601 documentation  | view source Contained in the MooseX-Types-ISO8601 distribution.