Skip to content

Commit

Permalink
winapi: Refactor GetDayOfWeek function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzee119 committed Jun 22, 2024
1 parent 2945074 commit 831c8dc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/winapi/timezoneapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ typedef struct

// Determine the day of the week given a year, month and day
// https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Methods_in_computer_code
static UCHAR GetDayOfWeek (SHORT year, UCHAR month, UCHAR day)
static UCHAR GetDayOfWeek (INT year, INT month, INT day)
{
return (day += month < 3 ? year-- : year - 2, 23 *
month / 9 + day + 4 + year / 4 - year / 100 + year / 400) % 7;
if (month < 3) {
day += year;
year--;
} else {
day += year - 2;
}
return (day + 23 * month / 9 + 4 + year / 4 - year / 100 + year / 400) % 7;
}

static UCHAR GetDaysInMonth (SHORT year, UCHAR month)
Expand Down

0 comments on commit 831c8dc

Please sign in to comment.