feat(libc): export timezone and daylight #8324

Merged
hypermoist merged 1 commit from upstream-pr/8324 into main 2026-10-21 07:57:09 +00:00
hypermoist commented 2026-10-20 10:06:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-20T10:06:02Z.


What

Adds the missing timezone (-Oet9AHzwtU, 8 bytes) and daylight (tOicWgmk4ZI, 4 bytes) data exports. The decrypted libSceLibcInternal.sprx keeps both in .bss (0x1c3260, 0x1c3268), so they are 0 until tzset runs, and only tzset (gYFKAMoNEfo) writes them:

  • t = time(0), then mktime(gmtime(&t)) and mktime(localtime(&t)); timezone = (long)difftime(first, second) (vcvttsd2si into [0x1c3260]). Because gmtime clears tm_isdst, this is the standard offset in seconds west of UTC, even while daylight saving is in effect.
  • daylight = localtime(&t)->tm_isdst >= 0 (not eax; shr eax, 0x1f into [0x1c3268]). So it is 1 whenever the zone's daylight saving state is known, not only for zones that have daylight saving.

tzset_nid_postfix now computes both the same way through the guest time, gmtime_s, localtime_s, mktime and difftime. Upstream refreshes tzname on an implicit TZ change; these two are left to tzset, as in firmware.

Tested

Linux (CachyOS, GCC, Release). guest_time_conversion_tests passes with new checks:

  • UTC+3 gives 10800 / 1;
  • an empty TZ gives 0 / 1;
  • EST5EDT gives 18000 / 1 on any date.

guest_mktime_tests still passes.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code), reviewed by the contributor

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4934194013 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8324). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-20T10:06:02Z. --- ### What Adds the missing `timezone` (`-Oet9AHzwtU`, 8 bytes) and `daylight` (`tOicWgmk4ZI`, 4 bytes) data exports. The decrypted `libSceLibcInternal.sprx` keeps both in `.bss` (`0x1c3260`, `0x1c3268`), so they are 0 until `tzset` runs, and only `tzset` (`gYFKAMoNEfo`) writes them: - `t = time(0)`, then `mktime(gmtime(&t))` and `mktime(localtime(&t))`; `timezone = (long)difftime(first, second)` (`vcvttsd2si` into `[0x1c3260]`). Because `gmtime` clears `tm_isdst`, this is the standard offset in seconds west of UTC, even while daylight saving is in effect. - `daylight = localtime(&t)->tm_isdst >= 0` (`not eax; shr eax, 0x1f` into `[0x1c3268]`). So it is 1 whenever the zone's daylight saving state is known, not only for zones that have daylight saving. `tzset_nid_postfix` now computes both the same way through the guest `time`, `gmtime_s`, `localtime_s`, `mktime` and `difftime`. Upstream refreshes `tzname` on an implicit TZ change; these two are left to `tzset`, as in firmware. ### Tested Linux (CachyOS, GCC, Release). `guest_time_conversion_tests` passes with new checks: - `UTC+3` gives 10800 / 1; - an empty TZ gives 0 / 1; - `EST5EDT` gives 18000 / 1 on any date. `guest_mktime_tests` still passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code), reviewed by the contributor 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
github-actions[bot] commented 2026-10-20 10:20:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T10:20:50Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 8546 core/libs/prx/libc/src/Time.cpp L522, L532-534

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4627 core/libs/prx/libc/src/Time.cpp
PR 5021 core/libs/prx/libc/src/Time.cpp
PR 6044 core/libs/tests/GuestTimeConversion.cpp
PR 7201 core/libs/prx/libc/src/Time.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6288731194 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8324#issuecomment-6288731194). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T10:20:50Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 8546](https://www.github.com/boykopovar/AnyPS5/pull/8546) | `core/libs/prx/libc/src/Time.cpp` [L522](https://github.com/boykopovar/AnyPS5/blob/9be6ccf60c44b4f91d428ed5788da92d07ca9a09/core/libs/prx/libc/src/Time.cpp#L522), [L532-534](https://github.com/boykopovar/AnyPS5/blob/9be6ccf60c44b4f91d428ed5788da92d07ca9a09/core/libs/prx/libc/src/Time.cpp#L532-L534) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 4627](https://www.github.com/boykopovar/AnyPS5/pull/4627) | `core/libs/prx/libc/src/Time.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libc/src/Time.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestTimeConversion.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libc/src/Time.cpp` |
xXPBSXx commented 2026-10-20 12:54:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T12:54:15Z.


Windows data point for e201141e0 merged onto main 44e3389c8 (clean, git merge-tree rc 0): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release. ctest -N -R '^guest_time_conversion$' lists exactly that one test; ctest --no-tests=error -R '^guest_time_conversion$' was run three times per tree.

  • With the PR: passes 3 of 3 (0.84-0.98 s).
  • Same tree with core/libs/prx/libc/src/Time.cpp restored to main (the new test cases kept): guest_time_conversion_tests does not link (undefined reference to 'timezone_nid_postfix' and 'daylight_nid_postfix'), so there is nothing to run without the change.
    Not tested: other platforms, a title run.
    AI-assisted (Claude Code).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6291313473 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8324#issuecomment-6291313473). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T12:54:15Z. --- Windows data point for `e201141e0` merged onto `main` `44e3389c8` (clean, `git merge-tree` rc 0): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release. `ctest -N -R '^guest_time_conversion$'` lists exactly that one test; `ctest --no-tests=error -R '^guest_time_conversion$'` was run three times per tree. - With the PR: passes 3 of 3 (0.84-0.98 s). - Same tree with `core/libs/prx/libc/src/Time.cpp` restored to `main` (the new test cases kept): `guest_time_conversion_tests` does not link (`undefined reference to 'timezone_nid_postfix'` and `'daylight_nid_postfix'`), so there is nothing to run without the change. Not tested: other platforms, a title run. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
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!8324
No description provided.