From b2f5721e58e94b918c5b7032e315396f4fb6c51d Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 20:20:19 -0400 Subject: COMMON: Add tm_wday to our TimeDate struct Did not adapt bada or ps2 backends as I'm not sure how they should be handled --- backends/platform/ps2/ps2time.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/platform/ps2/ps2time.cpp') diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp index 2c3275b2b2..c8da0f4915 100644 --- a/backends/platform/ps2/ps2time.cpp +++ b/backends/platform/ps2/ps2time.cpp @@ -120,4 +120,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; + t.tm_wday = 0; // FIXME } -- cgit v1.2.3 From 249d48f77b395d82b8f2bb67360c5539212f5bc4 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 10 Jun 2012 14:53:26 -0400 Subject: BACKENDS: Add #error for platforms not setting tm_wday in release builds --- backends/platform/ps2/ps2time.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'backends/platform/ps2/ps2time.cpp') diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp index c8da0f4915..decfc552ec 100644 --- a/backends/platform/ps2/ps2time.cpp +++ b/backends/platform/ps2/ps2time.cpp @@ -120,5 +120,9 @@ 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 } -- cgit v1.2.3 From 954d56a30fcde8b72c30d8fdfa7ad68945d3ac96 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Mon, 18 Jun 2012 20:21:22 +0100 Subject: PS2: Implement algorithm for day of week for use in tm_wday. --- backends/platform/ps2/ps2time.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'backends/platform/ps2/ps2time.cpp') diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp index decfc552ec..124c154d06 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); } -- cgit v1.2.3 From f92f9f9faf34d378939761e211649572ec72cd25 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 19 Jun 2012 01:48:21 +0200 Subject: PS2: Small formatting fixes. --- backends/platform/ps2/ps2time.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/platform/ps2/ps2time.cpp') diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp index 124c154d06..1cddd230a0 100644 --- a/backends/platform/ps2/ps2time.cpp +++ b/backends/platform/ps2/ps2time.cpp @@ -107,9 +107,9 @@ void OSystem_PS2::readRtcTime(void) { // 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}; + 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; + return (y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7; } void OSystem_PS2::getTimeAndDate(TimeDate &t) const { -- cgit v1.2.3