浏览代码

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.

(cherry picked from commit aae5f246ff3b29a6a60d438d71523c8cc139be1b)
Maganty Rushyendra 5 年之前
父节点
当前提交
cd3a3eb3eb
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      core/bind/core_bind.cpp

+ 1 - 1
core/bind/core_bind.cpp

@@ -868,7 +868,7 @@ Dictionary _OS::get_datetime_from_unix_time(int64_t unix_time_val) const {
 	} else {
 	} else {
 		dayno = (unix_time_val - SECS_DAY + 1) / SECS_DAY;
 		dayno = (unix_time_val - SECS_DAY + 1) / SECS_DAY;
 		dayclock = unix_time_val - dayno * SECS_DAY;
 		dayclock = unix_time_val - dayno * SECS_DAY;
-		date.weekday = static_cast<OS::Weekday>((dayno - 3) % 7 + 7);
+		date.weekday = static_cast<OS::Weekday>(((dayno % 7) + 11) % 7);
 		do {
 		do {
 			year--;
 			year--;
 			dayno += YEARSIZE(year);
 			dayno += YEARSIZE(year);