in reply to Date to Day
################################################################## +######### # # day_of_week($year, $month, $day) # # Valid from 14 September 1752 onwards. $month and $day are 1 inde +xed. # # 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; }
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Date to Day
by JoeJaz (Monk) on Aug 25, 2004 at 22:17 UTC |