static u32 sceRtcGetCurrentClockLocalTime(u32 pspTimePtr) { DEBUG_LOG(SCERTC, "sceRtcGetCurrentClockLocalTime(%08x)", pspTimePtr); PSPTimeval tv; __RtcTimeOfDay(&tv); time_t sec = (time_t) tv.tv_sec; tm *local = localtime(&sec); if (!local) { ERROR_LOG(SCERTC, "Date is too high/low to handle, pretending to work."); return 0; } ScePspDateTime ret; __RtcTmToPspTime(ret, local); ret.microsecond = tv.tv_usec; if (Memory::IsValidAddress(pspTimePtr)) Memory::WriteStruct(pspTimePtr, &ret); hleEatCycles(2000); hleReSchedule("rtc current clock local"); return 0; }
u32 sceRtcGetCurrentClock(u32 pspTimePtr, int tz) { DEBUG_LOG(HLE, "sceRtcGetCurrentClock(%08x, %d)", pspTimePtr, tz); PSPTimeval tv; __RtcTimeOfDay(&tv); time_t sec = (time_t) tv.tv_sec; tm *utc = gmtime(&sec); if (!utc) { ERROR_LOG(HLE, "Date is too high/low to handle, pretending to work."); return 0; } utc->tm_isdst = -1; utc->tm_min += tz; rtc_timegm(utc); // Return gmt time with timezone offset. ScePspDateTime ret; __RtcTmToPspTime(ret, utc); ret.microsecond = tv.tv_usec; if (Memory::IsValidAddress(pspTimePtr)) Memory::WriteStruct(pspTimePtr, &ret); hleEatCycles(1900); return 0; }
u32 sceRtcGetCurrentClockLocalTime(u32 pspTimePtr) { DEBUG_LOG(HLE, "sceRtcGetCurrentClockLocalTime(%08x)", pspTimePtr); timeval tv; gettimeofday(&tv, NULL); time_t sec = (time_t) tv.tv_sec; tm *local = localtime(&sec); if (!local) { ERROR_LOG(HLE, "Date is too high/low to handle, pretending to work."); return 0; } ScePspDateTime ret; __RtcTmToPspTime(ret, local); ret.microsecond = tv.tv_usec; if (Memory::IsValidAddress(pspTimePtr)) Memory::WriteStruct(pspTimePtr, &ret); return 0; }