From aae5f246ff3b29a6a60d438d71523c8cc139be1b Mon Sep 17 00:00:00 2001 From: Maganty Rushyendra Date: Mon, 29 Jun 2020 14:27:10 +0800 Subject: [PATCH] Fix weekday calculation in get_datetime_from_unix_time for negative times Fix calculation for negative times to ensure Sundays are wrapped around to '0' instead of '7', making it consistent with the output for positive times. --- core/bind/core_bind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 267391c4d6b..cb82dc7f8f0 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -454,7 +454,7 @@ Dictionary _OS::get_datetime_from_unix_time(int64_t unix_time_val) const { } else { dayno = (unix_time_val - SECS_DAY + 1) / SECS_DAY; dayclock = unix_time_val - dayno * SECS_DAY; - date.weekday = static_cast((dayno - 3) % 7 + 7); + date.weekday = static_cast(((dayno % 7) + 11) % 7); do { year--; dayno += YEARSIZE(year);