# NOTE: Derived from web_diary_dir/lib/DateTime/Date.pm.
# Changes made here will be lost when autosplit again.
# See AutoSplit.pm.
package DateTime::Date;

#line 468 "web_diary_dir/lib/DateTime/Date.pm (autosplit into web_diary_dir/lib/auto/DateTime/Date/Decrement.al)"
sub Decrement ($;$)
{
    my ($self, $quantity) = @_;
    my ($num, $unit) = $quantity =~ /^(\d+)([YMD])$/;

    if ($quantity eq '1'){
	$num = 1;
	$unit = 'D';
    }
    if ($unit eq 'D'){
	for (1..$num){
	    if ($self->day > 1){
		$self->day($self->day-1);
	    } else {
		$self->Decrement("1M");
		$self->day($self->DaysMonth($self->month));
	    }
	}
    } elsif ($unit eq 'M'){
	for (1..$num){
	    if ($self->month > 1){
		$self->month($self->month-1);
	    } else{
		$self->month(12);
		$self->year($self->year-1);
	    }
	}
    } elsif ($unit eq 'Y'){
	$self->year($self->year-$num);
    } else {
	die "illegal operator $quantity";
    }
    return $self;
}

# end of DateTime::Date::Decrement
1;
