Hi Ron,

I'm a bit confused by your parameters to day_of_week().

This is the actual implementation from DateTime.pm

    sub day_of_week { $_[0]->{local_c}{day_of_week} }

-J

--
> ========================script=========================
>
> use strict;
> use warnings;
> use DateTime;
>
> my $dt = DateTime->new( year => 2001 );
> my $num = number_of_sundays($dt);
> print $num;
>
> sub number_of_sundays {
>
>     my ($dt) = @_;
>     my $dt2 = $dt->clone();
>
>     if ( $dt->is_leap_year ) {
>
>         my $dow = $dt2->day_of_week(
>           year  => $dt->year,
>           month => 1,
>           day   => 1,
>         );
>         return 53 if ( $dow == 7 or $dow == 6 );
>
>     }
>     else {
>
>         my $dow = $dt2->day_of_week(
>           year  => $dt->year,
>           month => 1,
>           day   => 1,
>         );
>         return 53 if ( $dow == 7 );
>     }
>
>     return 52;
> }
>

Reply via email to