The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Module::Generic::DateTime::Interval - An Enhanced DateTime::Duration Object

SYNOPSIS

    use Module::Generic::DateTime::Interval;
    my $int = Module::Generic::DateTime::Interval->new( $duration );
    # Inspect by returning a formatted string showing year, month, etc
    print( $int->dump, "\n" );
    $int->days = 10;
    my $days = $int->days;
    $int->hours = 10;
    my $hours = $int->hours;
    $int->minutes = 10;
    my $minutes = $int->minutes;
    $int->months = 10;
    my $months = $int->months;
    $int->nanoseconds = 10;
    my $nano = $int->nanoseconds;
    $int->seconds = 10;
    my $seconds = $int->seconds;
    $int->weeks = 10;
    my $weeks = $int->weeks;
    $int->years = 10;
    my $years = $int->years;

    my $dt = DateTime->now;
    my $dt2 = DateTime->now->add( days => 10 );
    # Get an Module::Generic::DateTime::Interval object
    my $int = $dt2 - $dt;
    print $int->days, "\n"; # 10

DESCRIPTION

Module::Generic::DateTime::Interval is a thin wrapper around DateTime::Duration to provide enhance features. All other regular method calls of DateTime::Duration are passed through to it via AUTOLOAD.

This interval object is overloaded and allows the following operations: +, -, *, comparison

METHODS

days

This is an lvalue method to set or get the number of days in this interval object.

Example:

    $int->days = 10;
    $int->days( 10 );
    my $days = $int->days;

hours

This is an lvalue method to set or get the number of hours in this interval object.

Example:

    $int->hours = 10;
    $int->hours( 10 );
    my $hours = $int->hours;

minutes

This is an lvalue method to set or get the number of minutes in this interval object.

Example:

    $int->minutes = 10;
    $int->minutes( 10 );
    my $minutes = $int->minutes;

months

This is an lvalue method to set or get the number of months in this interval object.

Example:

    $int->months = 10;
    $int->months( 10 );
    my $months = $int->months;

nanoseconds

This is an lvalue method to set or get the nanoseconds of days in this interval object.

Example:

    $int->nanoseconds = 10;
    $int->nanoseconds( 10 );
    my $nanoseconds = $int->nanoseconds;

seconds

This is an lvalue method to set or get the seconds of days in this interval object.

Example:

    $int->seconds = 10;
    $int->seconds( 10 );
    my $seconds = $int->seconds;

weeks

This is an lvalue method to set or get the weeks of days in this interval object.

Example:

    $int->weeks = 10;
    $int->weeks( 10 );
    my $weeks = $int->weeks;

years

This is an lvalue method to set or get the years of days in this interval object.

Example:

    $int->years = 10;
    $int->years( 10 );
    my $years = $int->years;

SERIALISATION

Serialisation by CBOR, Sereal and Storable is supported by this package. To that effect, the following subroutines are implemented: FREEZE, THAW, STORABLE_freeze and STORABLE_thaw

SEE ALSO

Module::Generic, Module::Generic::DateTime, DateTime, DateTime::Format::Strptime, DateTime::TimeZone

AUTHOR

Jacques Deguest <jack@deguest.jp>

COPYRIGHT & LICENSE

Copyright (c) 2000-2020 DEGUEST Pte. Ltd.

You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.