mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
os-independent weekday calculation
This commit is contained in:
parent
70eb0d4e66
commit
7f51eed107
|
@ -126,11 +126,10 @@ date date::today()
|
||||||
|
|
||||||
int date::weekday() const
|
int date::weekday() const
|
||||||
{
|
{
|
||||||
#ifndef _MSC_VER
|
std::tm tm{0};
|
||||||
std::tm tm{0, 0, 0, day, month - 1, year - 1900, 0, 0, 0, 0, nullptr};
|
tm.tm_mday = day;
|
||||||
#else
|
tm.tm_mon = month - 1;
|
||||||
std::tm tm{0, 0, 0, day, month - 1, year - 1900, 0, 0, 0};
|
tm.tm_year = year - 1900;
|
||||||
#endif
|
|
||||||
std::time_t time = std::mktime(&tm);
|
std::time_t time = std::mktime(&tm);
|
||||||
|
|
||||||
return safe_localtime(time).tm_wday;
|
return safe_localtime(time).tm_wday;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user