[Scummvm-cvs-logs] scummvm master -> 88512351d0e265bec0f85c09a7cc9bb388fef4f4

lordhoto lordhoto at gmail.com
Tue Jun 19 01:47:14 CEST 2012


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
954d56a30f PS2: Implement algorithm for day of week for use in tm_wday.
88512351d0 Merge pull request #249 from digitall/PS2DayOfWeek


Commit: 954d56a30fcde8b72c30d8fdfa7ad68945d3ac96
    https://github.com/scummvm/scummvm/commit/954d56a30fcde8b72c30d8fdfa7ad68945d3ac96
Author: D G Turner (digitall at scummvm.org)
Date: 2012-06-18T12:21:22-07:00

Commit Message:
PS2: Implement algorithm for day of week for use in tm_wday.

Changed paths:
    backends/platform/ps2/ps2time.cpp



diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp
index decfc55..124c154 100644
--- a/backends/platform/ps2/ps2time.cpp
+++ b/backends/platform/ps2/ps2time.cpp
@@ -105,8 +105,14 @@ void OSystem_PS2::readRtcTime(void) {
 		g_day, g_month, g_year + 2000);
 }
 
-void OSystem_PS2::getTimeAndDate(TimeDate &t) const {
+// Tomohiko Sakamoto's 1993 algorithm for any Gregorian date
+static int dayOfWeek(int y, int m, int d) {
+	static const int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
+	y -= m < 3;
+	return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
+}
 
+void OSystem_PS2::getTimeAndDate(TimeDate &t) const {
 	uint32 currentSecs = g_timeSecs + (msecCount - g_lastTimeCheck) / 1000;
 	if (currentSecs >= SECONDS_PER_DAY) {
 		buildNewDate(+1);
@@ -120,9 +126,5 @@ void OSystem_PS2::getTimeAndDate(TimeDate &t) const {
 	t.tm_year = g_year + 100;
 	t.tm_mday = g_day;
 	t.tm_mon  = g_month - 1;
-#ifdef RELEASE_BUILD
-	#error getTimeAndDate() is not setting the day of the week
-#else
-	t.tm_wday = 0; // FIXME
-#endif
+	t.tm_wday = dayOfWeek(t.tm_year, t.tm_mon, t.tm_mday);
 }


Commit: 88512351d0e265bec0f85c09a7cc9bb388fef4f4
    https://github.com/scummvm/scummvm/commit/88512351d0e265bec0f85c09a7cc9bb388fef4f4
Author: Johannes Schickel (lordhoto at gmail.com)
Date: 2012-06-18T16:46:56-07:00

Commit Message:
Merge pull request #249 from digitall/PS2DayOfWeek

PS2: Implement algorithm for day of week for use in tm_wday.

Changed paths:
    backends/platform/ps2/ps2time.cpp









More information about the Scummvm-git-logs mailing list