in reply to Finding the Day of Week in Windows
This method will take a day, month and year and tell you what day of the week it was/is/will be.
I know this doesn't make sense to the human eye, but believe me, its an official algorithm for calculating the day of the week. I've just taken the algorithm and turned it into a perl version. If you want more info, search google for something like http://www.google.com/search?q=calculate+the+day+of+the+week
As with localtime, the algorithm returns a number that relates to the day of the week. By using the return as the index to an anonymous array, we get the actual day.sub dow { ($year, $month, $day) = @_; $year-- if $month < 3; return ($year+int($year/4)-int($year/100)+int($year/400)+((0,3,2,5 +,0,3,5,1,4,6,2,4)[$month-1])+$day) % 7; } print (('Sun','Mon','Tues','Wed','Thu','Fri','Sat')[dow(2002,07,12)]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Finding the Day of Week in Windows
by osama (Scribe) on Jan 07, 2003 at 05:10 UTC | |
by BigLug (Chaplain) on Jan 07, 2003 at 13:01 UTC |