diff options
author | Matthew Hoops | 2012-06-24 09:37:53 -0400 |
---|---|---|
committer | Matthew Hoops | 2012-06-24 09:37:53 -0400 |
commit | 91efe792d5b231752dd16888729a94f323363fa0 (patch) | |
tree | e7346f83d4966ff4f3cf7e593a7f0cfa16c45b20 /backends/platform/ps2/ps2time.cpp | |
parent | 915a8399c910fb5c8e35de58857ce1577c1a0151 (diff) | |
parent | 20b677080881580706652b17dd5a4c3ed3e36c07 (diff) | |
download | scummvm-rg350-91efe792d5b231752dd16888729a94f323363fa0.tar.gz scummvm-rg350-91efe792d5b231752dd16888729a94f323363fa0.tar.bz2 scummvm-rg350-91efe792d5b231752dd16888729a94f323363fa0.zip |
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'backends/platform/ps2/ps2time.cpp')
-rw-r--r-- | backends/platform/ps2/ps2time.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp index 2c3275b2b2..1cddd230a0 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,4 +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; + t.tm_wday = dayOfWeek(t.tm_year, t.tm_mon, t.tm_mday); } |