]> git.donarmstrong.com Git - deb_pkgs/libhtml-calendarmonth-perl.git/blobdiff - lib/HTML/CalendarMonth/DateTool/DateManip.pm
* Fix FTBFS caused by new version of Date::Manip (closes: 571421)
[deb_pkgs/libhtml-calendarmonth-perl.git] / lib / HTML / CalendarMonth / DateTool / DateManip.pm
index 0dadef070fe2f6ad850ff29c214cde6a532c00ab..3ed893c1163ad0705e4803e8ae56eff7a7eac6d0 100644 (file)
@@ -9,7 +9,7 @@ use vars qw(@ISA $VERSION);
 
 @ISA = qw(HTML::CalendarMonth::DateTool);
 
-$VERSION = '0.01';
+$VERSION = '0.02';
 
 use Date::Manip qw(Date_DaysInMonth Date_DayOfWeek DateCalc
                    UnixDate Date_SecsSince1970);
@@ -47,12 +47,12 @@ sub dow {
 
 sub add_days {
   my($self, $delta, $day, $month, $year) = @_;
-  $delta || croak "Delta (in days) required.\n";
+  defined $delta || croak "Delta (in days) required.\n";
   $day   || croak "Day required.\n";
   $month ||= $self->month;
   $year  ||= $self->year;
   my $date = DateCalc(sprintf("%04d%02d%02d", $year, $month, $day),
-                      "+ $delta days");
+                      ($delta < 0 ? '':'+')." $delta days");
   my($y, $m, $d) = $date =~ /^(\d{4})(\d\d)(\d\d)/;
   $_ += 0 foreach ($y, $m, $d);
   ($d, $m, $y);