Repository navigation
fix(libkernel): convert local time with the host time zone - #5096
Conversation
sceKernelConvertUtcToLocaltime and sceKernelConvertLocaltimeToUtc returned the time unchanged while libc localtime follows the host zone, so a title that mixes them shows UTC as local time (boykopovar#5067). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
fix(libkernel): convert local time with the host time zone
PPSA99203 (PS5SX2) documents that the console fills west_sec with the offset east of UTC despite the field's name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
…ts section Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
|
fixed conflict. |
|
Review note (static, nothing built): (1) The description says AI-assisted (Claude Code). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
|
Please check updated description. Thanks. |
|
These are notes on how the PS5
So I think AI-assisted (Claude Code). |
…elConvertLocaltimeToUtc libc mktime subtracts it when tm_isdst is set outside summer time, so it must not be zero there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
|
Thanks, this is really useful. You’re right: with dst_seconds at 0 outside summer time, that mktime branch never fires. Fixed in 15969f2: sceKernelConvertLocaltimeToUtc now writes the zone’s daylight saving amount to *dst_seconds whether or not it’s in effect (found by checking the host zone over the surrounding year, so it works in both hemispheres, and 0 for zones without DST), while timesec.dst_sec stays the amount in effect for localtime’s tm_isdst. The test now expects 3600 for EST5EDT in January as well as July, and the debt entry cites your PPSA99109 offsets (0x70ebb-0x70ee5). I left reserved/tm_isdst unused for now: I can’t check how the console uses it to pick the hour when the clock goes back, so it’s recorded as debt rather than guessed. Happy to add it in this PR or a follow-up if you’ve seen how the kernel side uses it. AI-assisted (Claude Code). |
|
Rebase handoff — rebased onto current Conflicts resolved across the two commits: main's settime-validation tests ( Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
# Conflicts: # core/libs/tests/GuestFreebsdClocks.cpp
|
Status update — all review points so far are addressed (head bb5f7d7):
Tested on Ubuntu 24.04 / GCC 13.3: Still untested on Windows. Could a maintainer start the full Build for this PR when convenient? |
…ndows A TZ variable does not set the UCRT's _dstbias, so after the system zone of a CI runner without daylight saving it stays 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
|
Windows run, since the description says Windows wasn't tested. Windows 11, RTX 4080, WinLibs GCC 15.2.0 r7, Release, this head (f5d856d) merged onto
Not covered: a Windows system zone without summer time, like a UTC CI runner. I didn't change this machine's zone. AI-assisted: yes (Claude Code Opus 5.5) |
|
Checked on Linux: the build and the libkernel ctest scope pass ( |
What
Fixes #5067.
sceKernelConvertUtcToLocaltimeandsceKernelConvertLocaltimeToUtcreturned the time unchanged, while libclocaltimefollows the host zone. PPSA99203 (PS5SX2) draws its on-screen clock and its settings log times fromsceKernelConvertUtcToLocaltimefollowed bygmtime_r(source). Because of that, it showed UTC as local time in #5067.tzsetfollowed bylocaltime_r/tm_gmtoff, withtimezonefor the standard part. On Windows it is_tzsetfollowed bylocaltime_s, with_get_timezone/_get_dstbias. These are the sources libclocaltime_suses. Windows times outside the CRT range move by whole 400-year cycles, as libc does.KernelTimesec.west_secholds the standard offset in seconds east of UTC, despite its name, anddst_secholds the daylight saving seconds in effect. This follows PS5SX2's own notes from a console, where the call wrote 7200 and 3600, and shadPS4, which also stores seconds east. Whetherwest_secincludes daylight saving is not settled, and the open question is recorded indocs/dev/debt/libkernel.md.localtime_sdoes (recorded as debt).sceKernelConvertLocaltimeToUtcfinds the offset in two passes. In a skipped or repeated local hour it takes the offset in effect one standard offset earlier (recorded as debt).sceKernelGettimezoneand thegettimeofdaytime zone are unchanged (no offset, no daylight saving) and recorded as debt. fix(libSceSystemService): report the host time zone and summer time #5084 makes the matching change forsceSystemServiceParamGetInt.Tested
Ubuntu 24.04, GCC 13.3, Release.
guest_freebsd_clockspasses. It now pinsTZand checks both directions forUTC0,IST-5:30(+5:30),BRT+3(-3:00) andEST5EDTin January (-5:00) and July (-4:00 with 3600 s of daylight saving), including theKernelTimesecfields. It also passes with no zoneinfo files (TZDIR=/nonexistent) and with a hostTZ=America/Toronto. The new checks abort on the previousTime.cpp. The existing identity and guard checks run underUTC0. Relinker-only build: all tests pass. Not tested on Windows or with a title.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)