DynGig-Range-Time
view release on metacpan or search on metacpan
lib/DynGig/Range/Time/Date.pm view on Meta::CPAN
=head1 NAME
DynGig::Range::Time::Date -
Extends DynGig::Range::Time::Parse and DynGig::Range::Time::Object.
=cut
package DynGig::Range::Time::Date;
use base DynGig::Range::Time::Parse;
use base DynGig::Range::Time::Object;
use warnings;
use strict;
use DateTime;
use DynGig::Range::Integer;
use overload '*=' => \&filter;
use constant { ABS => 0, REL => 1 };
my %_ENV = ( timezone => 'UTC' );
=head1 METHODS
See base class for additional methods.
=head2 setenv( timezone => $TZ )
Sets private environment variable I<timezone>. Returns object/class.
=cut
sub setenv
{
my ( $this, %param ) = @_;
map { $_ENV{$_} = $param{$_} if defined $param{$_} } keys %_ENV;
return $this;
}
=head2 abs()
Returns absolute time.
=cut
sub abs
{
my ( $this ) = @_;
return $this->[ABS];
}
=head2 rel()
Returns relative time.
=cut
sub rel
{
my ( $this ) = @_;
return $this->[REL];
}
=head2 sec2hms( seconds )
Converts seconds into a HASH of hour, minute, second. Returns HASH referece.
=cut
sub sec2hms
{
my ( $this, $sec ) = @_;
my %hms;
if ( $sec )
{
$hms{hour} = int( $sec / 3600 );
$sec %= 3600;
$hms{minute} = int( $sec / 60 );
$sec %= 60;
$hms{second} = $sec;
}
return \%hms;
}
=head2 filter( object )
Overloads B<*=>.
Returns the object after I<semantic> intersection with another object.
=cut
sub filter
{
my ( $this, $that ) = @_;
( run in 1.080 second using v1.01-cache-2.11-cpan-39bf76dae61 )