Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

winapi: Refactor GetDayOfWeek function #671

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading