Skip to content

fix(libkernel): convert local time with the host time zone - #1

Merged
sguckiran merged 1 commit into
mainfrom
claude/relaxed-cannon-a5ed3f
Oct 13, 2026
Merged

sguckiran merged 1 commit into
mainfrom
claude/relaxed-cannon-a5ed3f

Conversation

@sguckiran

@sguckiran sguckiran commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

What

Fixes boykopovar#5067. sceKernelConvertUtcToLocaltime and sceKernelConvertLocaltimeToUtc returned the time unchanged, while libc localtime follows the host zone. PPSA99203 (PS5SX2) draws its on-screen clock and its settings log times from sceKernelConvertUtcToLocaltime followed by gmtime_r (source). Because of that, it showed UTC as local time in boykopovar#5067.

  • Both conversions now use the host zone's offset at the given instant: localtime_r/tm_gmtoff on POSIX and localtime_s with _get_timezone/_get_dstbias on Windows, the same sources libc localtime_s uses. Windows times outside the CRT range move by whole 400-year cycles, as libc does.
  • KernelTimesec.west_sec holds the standard offset in seconds east of UTC, despite its name, and dst_sec holds 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. Whether west_sec includes daylight saving is not settled, and the open question is recorded in docs/dev/debt/libkernel.md.
  • sceKernelConvertLocaltimeToUtc finds 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).
  • sceKernelGettimezone and the gettimeofday time zone are unchanged (no offset, no daylight saving) and recorded as debt. fix(libSceSystemService): report the host time zone and summer time boykopovar/AnyPS5#5084 makes the matching change for sceSystemServiceParamGetInt.

Tested

Ubuntu 24.04, GCC 13.3, Release. guest_freebsd_clocks passes. It now pins TZ and checks both directions for UTC0, IST-5:30 (+5:30), BRT+3 (-3:00) and EST5EDT in January (-5:00) and July (-4:00 with 3600 s of daylight saving), including the KernelTimesec fields. It also passes with no zoneinfo files (TZDIR=/nonexistent) and with a host TZ=America/Toronto. The new checks abort on the previous Time.cpp. The existing identity and guard checks run under UTC0. Relinker-only build: all tests pass. Not tested on Windows or with a title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk

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
@sguckiran
sguckiran merged commit 8872da1 into main Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libkernel/libc: the time zone is UTC in sceKernelConvertUtcToLocaltime but the host's in localtime

2 participants