From 7f51eed1079c7194d9cbbefd9fb7309b44abf073 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Sun, 21 Feb 2021 08:18:26 -0400 Subject: [PATCH] os-independent weekday calculation --- source/utils/date.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/utils/date.cpp b/source/utils/date.cpp index 96afc161..90e87b23 100644 --- a/source/utils/date.cpp +++ b/source/utils/date.cpp @@ -126,11 +126,10 @@ date date::today() int date::weekday() const { -#ifndef _MSC_VER - std::tm tm{0, 0, 0, day, month - 1, year - 1900, 0, 0, 0, 0, nullptr}; -#else - std::tm tm{0, 0, 0, day, month - 1, year - 1900, 0, 0, 0}; -#endif + std::tm tm{0}; + tm.tm_mday = day; + tm.tm_mon = month - 1; + tm.tm_year = year - 1900; std::time_t time = std::mktime(&tm); return safe_localtime(time).tm_wday;