News for hackers. Stuff that matters.
Re:Day of Week Algorithm by cuoverhere on Friday March 25, 2016 @04:31PM (#11362469)
perl!

  sub GetDayofWeek {

    my ($year, $month, $day) = @_;
    
     my @monthTable = (0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4);
     
     my @DayofWeek = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday);
     
     $year -=  ($month < 3) ? 1: 0;
     
     return $DayofWeek[($year + $year / 4 - $year / 100 + $year / 400 + $monthTable[$month - 1] + $day) % 7];
       
  }

There are no comments on this comment yet.