DateTime-Moonpig
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/DateTime/Moonpig.pm view on Meta::CPAN
use namespace::autoclean;
sub new {
my ($base, @arg) = @_;
my $class = ref($base) || $base;
if (@arg == 1) { return $class->from_epoch( epoch => $arg[0] ) }
my %arg = @arg;
$arg{time_zone} = 'UTC' unless exists $arg{time_zone};
bless $class->SUPER::new(%arg) => $class;
}
sub new_datetime {
my ($class, $dt) = @_;
bless $dt->clone => $class;
}
# $a is expected to be epoch seconds
sub plus {
my ($self, $a) = @_;
my $class = ref($self);
my $a_sec = $class->_to_sec($a);
return $class->from_epoch( epoch => $self->epoch + $a_sec,
time_zone => $self->time_zone,
);
t/lib/MyDaysInterval.pm view on Meta::CPAN
package MyDaysInterval; # Silly example
sub new {
my ($class, $days) = @_;
bless { days => $days } => $class;
}
sub as_seconds { $_[0]{days} * 86400 }
1;
is($x0->st, "1969-04-02 02:38:10", "x0");
$z4 = $x0 - $birthday; # 10
is($z4, 10, "z4");
$z5 = $birthday - $x0; # -10
is($z5, -10, "z5");
package Feb13; # Silly example
sub new {
my ($class) = @_;
bless [ "DUMMY" ] => $class;
}
sub epoch { return 1234567890 } # Feb 13 23:31:30 2009 UTC
package main;
my $feb13 = Feb13->new();
$feb13_dt = DateTime->new( year => 2009,
month => 2,
day => 13,
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.995 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )