# 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 216 "web_diary_dir/lib/DateTime/Date.pm (autosplit into web_diary_dir/lib/auto/DateTime/Date/IsHolyday.al)"
sub IsHolyday ($)
{
    my $self = shift;

 
    my ($year, $month, $day) = ($self->year, $self->month, $self->day);
    my $week = $self->week;
    
    # 祝日
    for (@Holydays){
	my ($m, $d) = @$_;
	if ($month == $m && $day == $d){
	    return 'H';
	}
    }
    # 春分、秋分
    if ($year >= 1900 && $year <= 2099){    # この間の簡易式を使う
	if ($month == 3){
	    my $s_day = int(0.24242 * $year -
			    int($year/4) + 35.84);
	    return 'H' if $day == $s_day;
	} elsif ($month == 9){
	    my $a_day = int(0.24204 * $year -
			    int($year/4) + 39.01);
	    return 'H' if $day == $a_day;
	}
    }

    # ハッピーマンデー
    if ($HappyMondayStartYear &&           # 定義してなきゃ適用せず
	$year >= $HappyMondayStartYear){
	if ($week == 1){
	    my $wn = $self->WeekNumber;
	    for (@HappyMonday){
		my ($m, $d, $n) = @$_;
		return 'M' if $month == $m && $wn == $n;
	    }
	}
    } else {              # 2000 年以前は普通
	for (@HappyMonday){
	    my ($m, $d, $n) = @$_;
	    return 'H' if $month == $m && $day == $d;
	}
    }
    return 'S' if $self->week == 0;    # 日曜は休み
    # 振り替え休日
    if ($week == 1){
	my $yesterday = new DateTime::Date(year=>$year,
					   month=>$month,
					   day=>$day);
	$yesterday--;
	if ($yesterday->IsHolyday eq 'H'){
	    return 'R';
	}
    }
    return undef;
}

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