I know its not what you asked for .. you're looking at localtime methods, but I'll contribute the following just for interests sake:
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
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)]);
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. |