Module::Generic::DateTime::Interval - An Enhanced DateTime::Duration Object
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
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.
AUTOLOAD
This interval object is overloaded and allows the following operations: +, -, *, comparison
+
-
*
comparison
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;
This is an lvalue method to set or get the number of hours in this interval object.
$int->hours = 10; $int->hours( 10 ); my $hours = $int->hours;
This is an lvalue method to set or get the number of minutes in this interval object.
$int->minutes = 10; $int->minutes( 10 ); my $minutes = $int->minutes;
This is an lvalue method to set or get the number of months in this interval object.
$int->months = 10; $int->months( 10 ); my $months = $int->months;
This is an lvalue method to set or get the nanoseconds of days in this interval object.
$int->nanoseconds = 10; $int->nanoseconds( 10 ); my $nanoseconds = $int->nanoseconds;
This is an lvalue method to set or get the seconds of days in this interval object.
$int->seconds = 10; $int->seconds( 10 ); my $seconds = $int->seconds;
This is an lvalue method to set or get the weeks of days in this interval object.
$int->weeks = 10; $int->weeks( 10 ); my $weeks = $int->weeks;
This is an lvalue method to set or get the years of days in this interval object.
$int->years = 10; $int->years( 10 ); my $years = $int->years;
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
FREEZE
THAW
STORABLE_freeze
STORABLE_thaw
Module::Generic, Module::Generic::DateTime, DateTime, DateTime::Format::Strptime, DateTime::TimeZone
Jacques Deguest <jack@deguest.jp>
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.
To install Module::Generic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Generic
CPAN shell
perl -MCPAN -e shell install Module::Generic
For more information on module installation, please visit the detailed CPAN module installation guide.