From ca881dd7e060da10d1399057b59f5e9523f7e7cb Mon Sep 17 00:00:00 2001 From: arbee Date: Wed, 31 May 2023 21:28:01 -0400 Subject: apple/macrtc.cpp: Don't cache the time reference, it's somehow different for different timezones. (GitHub #11298) [R. Belmont] --- src/mame/apple/macrtc.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mame/apple/macrtc.cpp b/src/mame/apple/macrtc.cpp index c14ad00e8f3..b66decf9785 100644 --- a/src/mame/apple/macrtc.cpp +++ b/src/mame/apple/macrtc.cpp @@ -45,8 +45,6 @@ enum RTC_STATE_XPWRITE }; -static constexpr uint32_t mac_reference = 0x83da95d0; // Seconds from January 1, 1904, 12:00:00 to when POSIX time starts - //************************************************************************** // LIVE DEVICE //************************************************************************** @@ -153,7 +151,7 @@ TIMER_CALLBACK_MEMBER(rtc3430042_device::half_seconds_tick) void rtc3430042_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) { - struct tm cur_time; + struct tm cur_time, macref; uint32_t seconds; if (m_time_was_set) @@ -171,7 +169,16 @@ void rtc3430042_device::rtc_clock_updated(int year, int month, int day, int day_ cur_time.tm_year = year+100; // assumes post-2000 current system time cur_time.tm_isdst = 0; - seconds = (uint32_t)((uint32_t)mktime(&cur_time) - mac_reference); + macref.tm_sec = 0; + macref.tm_min = 0; + macref.tm_hour = 0; + macref.tm_mday = 1; + macref.tm_mon = 0; + macref.tm_year = 4; + macref.tm_isdst = 0; + uint32_t ref = (uint32_t)mktime(¯ef); + + seconds = (uint32_t)((uint32_t)mktime(&cur_time) - ref); } LOG("second count 0x%lX\n", (unsigned long) seconds); -- cgit v1.2.3