Algorithm by Tomohiko Sakamoto from the C FAQ, section 20.31.
###################################################################### +######### # # day_of_week($year, $month, $day) # # Valid from 14 September 1752 onwards. $month and $day are 1 indexed. # # Returns: 0 .. 6 where 0 is Sunday. # # Algorithm by Tomohiko Sakamoto from the C FAQ, section 20.31. # sub day_of_week { my ($year, $month, $day) = @_; my @offset = (0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4); $year -= $month < 3; return ($year + int($year/4) - int($year/100) + int($year/400) + $offset[$month-1] + $day) % 7; }
See also Day of week for an arbitary date using core modules, Date::Calc, Date::Manip, Time::Piece.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Day of the week
by RMGir (Prior) on Apr 11, 2003 at 11:50 UTC | |
by jmcnamara (Monsignor) on Apr 11, 2003 at 12:31 UTC |