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

Closed
opened 2026-10-13 10:23:16 +00:00 by nicolasfalesy · 1 comment
nicolasfalesy commented 2026-10-13 10:23:16 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T10:23:16Z.


A question about intended behaviour, not a crash.

libkernel/Time/Time.cpp keeps the console clock in UTC on purpose (the comment above sceKernelClockGetres: "the time zone reported here and by gettimeofday has no offset and no daylight saving"). So sceKernelConvertUtcToLocaltime and sceKernelConvertLocaltimeToUtc return the time unchanged, and sceKernelGettimezone reports zero.

libc/src/Time.cpp does the opposite: localtime/localtime_s use the host's zone (TZ defaults to :/etc/localtime, then tzset).

So one title can get two different local times. On Linux (main 7e181fcc3, host zone America/Toronto, UTC−4), PS5SX2 (PPSA99203, with #4776) imports both localtime and sceKernelConvertUtcToLocaltime, and its frontend clock showed 06:04 at 02:04 local time. Titles that use only libc localtime show the host's time.

Which is intended: should the kernel conversions follow the host zone like libc does, or should libc report UTC to match the kernel? I haven't checked which of the two PS5SX2 uses for that clock.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5828630261 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5067). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-13T10:23:16Z. --- A question about intended behaviour, not a crash. `libkernel/Time/Time.cpp` keeps the console clock in UTC on purpose (the comment above `sceKernelClockGetres`: "the time zone reported here and by gettimeofday has no offset and no daylight saving"). So `sceKernelConvertUtcToLocaltime` and `sceKernelConvertLocaltimeToUtc` return the time unchanged, and `sceKernelGettimezone` reports zero. `libc/src/Time.cpp` does the opposite: `localtime`/`localtime_s` use the host's zone (`TZ` defaults to `:/etc/localtime`, then `tzset`). So one title can get two different local times. On Linux (`main` 7e181fcc3, host zone America/Toronto, UTC−4), PS5SX2 (PPSA99203, with #4776) imports both `localtime` and `sceKernelConvertUtcToLocaltime`, and its frontend clock showed 06:04 at 02:04 local time. Titles that use only libc `localtime` show the host's time. Which is intended: should the kernel conversions follow the host zone like libc does, or should libc report UTC to match the kernel? I haven't checked which of the two PS5SX2 uses for that clock.
MarcZX10 commented 2026-10-13 12:42:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T12:42:37Z.


The discrepancy is accounted for by the title path: PS5SX2 derives its visible clock from sceKernelConvertUtcToLocaltime, while libc localtime uses the host time zone. Open PR #5096 addresses this by making both kernel conversion functions use the host zone, matching libc. It leaves sceKernelGettimezone unchanged because that call’s console behavior has not been established; #5084 separately handles SystemService’s time-zone and summer-time parameters. These changes are still under review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6145798229 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5067#issuecomment-6145798229). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T12:42:37Z. --- The discrepancy is accounted for by the title path: PS5SX2 derives its visible clock from `sceKernelConvertUtcToLocaltime`, while libc `localtime` uses the host time zone. Open PR #5096 addresses this by making both kernel conversion functions use the host zone, matching libc. It leaves `sceKernelGettimezone` unchanged because that call’s console behavior has not been established; #5084 separately handles SystemService’s time-zone and summer-time parameters. These changes are still under review.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#5067
No description provided.