"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Class/Date/Rel.pm" between
Class-Date-1.1.16.tar.gz and Class-Date-1.1.17.tar.gz

About: Class-Date provides a date datatype for Perl.

Rel.pm  (Class-Date-1.1.16):Rel.pm  (Class-Date-1.1.17)
package Class::Date::Rel; package Class::Date::Rel;
our $AUTHORITY = 'cpan:YANICK'; our $AUTHORITY = 'cpan:YANICK';
$Class::Date::Rel::VERSION = '1.1.17';
use strict; use strict;
use warnings; use warnings;
use vars qw(@NEW_FROM_SCALAR); use vars qw(@NEW_FROM_SCALAR);
use Class::Date::Const; use Class::Date::Const;
use Scalar::Util qw(blessed); use Scalar::Util qw(blessed);
our $VERSION = '1.1.15';
use constant SEC_PER_MONTH => 2_629_744; use constant SEC_PER_MONTH => 2_629_744;
# see the ClassDateRel const in package Class::Date # see the ClassDateRel const in package Class::Date
use constant ClassDate => "Class::Date"; use constant ClassDate => "Class::Date";
use overload use overload
'0+' => "sec", '0+' => "sec",
'""' => "sec", '""' => "sec",
'<=>' => "compare", '<=>' => "compare",
'cmp' => "compare", 'cmp' => "compare",
'+' => "add", '+' => "add",
'neg' => "neg", 'neg' => "neg",
fallback => 1; fallback => 1;
sub new { my ($proto,$val)=@_; sub new { my ($proto,$val)=@_;
my $class = ref($proto) || $proto; my $class = ref($proto) || $proto;
return undef if !defined $val; return undef if !defined $val;
if (blessed($val) && $val->isa( __PACKAGE__ )) {
return $class->new_copy($val); my $ref = ref $val or return $class->new_from_scalar($val);
} elsif (ref($val) eq 'ARRAY') {
return $class->new_from_array($val); return $class->new_copy($val)
} elsif (ref($val) eq 'HASH') { if (blessed($val) && $val->isa( __PACKAGE__ ));
return $class->new_from_hash($val);
} elsif (ref($val) eq 'SCALAR') { return $class->new_from_array($val) if $ref eq 'ARRAY';
return $class->new_from_scalar($$val);
} else { return $class->new_from_hash($val) if $ref eq 'HASH';
return $class->new_from_scalar($val);
}; # can only be a scalar ref by now
return $class->new_from_scalar($$val);
} }
sub new_copy { my ($s,$val)=@_; sub new_copy { my ($s,$val)=@_;
return bless([@$val], ref($s)||$s); return bless([@$val], ref($s)||$s);
} }
sub new_from_array { my ($s,$val) = @_; sub new_from_array { my ($s,$val) = @_;
my ($y,$m,$d,$hh,$mm,$ss) = @$val; my ($y,$m,$d,$hh,$mm,$ss) = @$val;
return bless([ ($y || 0) * 12 + $m , ($ss || 0) + return bless([ ($y || 0) * 12 + $m , ($ss || 0) +
60*(($mm || 0) + 60*(($hh || 0) + 24* ($d || 0))) ], ref($s)||$s); 60*(($mm || 0) + 60*(($hh || 0) + 24* ($d || 0))) ], ref($s)||$s);
skipping to change at line 157 skipping to change at line 157
=pod =pod
=encoding UTF-8 =encoding UTF-8
=head1 NAME =head1 NAME
Class::Date::Rel Class::Date::Rel
=head1 VERSION =head1 VERSION
version 1.1.16 version 1.1.17
=head1 AUTHORS =head1 AUTHORS
=over 4 =over 4
=item * =item *
dLux (Szabó, Balázs) <dlux@dlux.hu> dLux (Szabó, Balázs) <dlux@dlux.hu>
=item * =item *
 End of changes. 4 change blocks. 
14 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)