Skip to content

Commit df7267c

Browse files
committed
Datetime: Compute eonw correctly on sundays
1 parent c1760be commit df7267c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/Datetime.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,9 +1939,11 @@ bool Datetime::initializeEonw (Pig& pig)
19391939
{
19401940
time_t now = time (nullptr);
19411941
struct tm* t = localtime (&now);
1942-
1943-
t->tm_mday += 15 - t->tm_wday;
19441942
t->tm_hour = t->tm_min = t->tm_sec = 0;
1943+
1944+
int extra = (t->tm_wday + 6) % 7;
1945+
t->tm_mday += 14 - extra;
1946+
19451947
t->tm_isdst = -1;
19461948
_date = mktime (t);
19471949
return true;

0 commit comments

Comments
 (0)