fix(libc): convert mktime before 1900 from the zone's own offsets on macOS #6686

Merged
DavidSamir merged 5 commits from upstream-pr/6686 into main 2026-10-19 08:59:57 +00:00
DavidSamir commented 2026-10-16 04:48:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T04:48:44Z.


What

On macOS a guest mktime of a time before 1900 returns -1, although localtime converts the same time. mktime hands the broken-down time to the host's mktime, and macOS's refuses every year before 1900. A standalone program on this Mac (TZ=UTC-2, 1 January at noon) gets -1 for the years 1, 1000, 1500, 1570, 1582, 1600, 1700, 1800, 1850 and 1883, and the right value from 1900 on.

On macOS mktime now solves a local time before 2 January 1900 directly. It subtracts the offset localtime_r gives for a candidate time from the local fields, and repeats until the offset holds, at most four times. localtime_r follows the zone's history: local mean time before its first transition, then early standard offsets such as Kolkata's MMT or Buenos Aires's CMT. So mktime(localtime(t)) returns t in region zones as well as fixed-offset ones. From 2 January 1900 on, the host's mktime still converts.

The first version moved such a time 400-year cycles later, as Windows does (#4811). jotitadev found in review that this applies the zone's modern rules to the moved year, so region zones were off by the LMT difference. The second commit replaces that on macOS.

The constants block is shared with Windows and keeps Windows's values (years 70 to 1100, first ordinary second one day, last 32535215999). The Windows conversion is otherwise unchanged, and Linux doesn't compile any of the changed lines. A tm_isdst set on a date where the zone had no daylight offset is taken as standard time. FreeBSD's time1 would shift it by the difference between one of the zone's daylight and standard types. The libc.md entry for localtime, mktime records this.

Commits:

  1. The 400-year move.
  2. Its debt entry.
  3. The offset solve that replaces the move on macOS.
  4. The region-zone test.
  5. The debt entry, rewritten.

Tested

macOS 26.7.1, Apple M2, AppleClang 21.0.0, x86-64 build under Rosetta, Release.

main does not build libc on macOS for other reasons as well (#4627 addresses them), so the test ran in a local tree of main ce991f1ec with #4627, #4630, #6124 and mugurc's macOS branches merged. This branch's Time.cpp is identical to the one tested, apart from #4627's tm_zone line.

  • main's Time.cpp: guest_time_conversion aborts with mktime did not invert localtime outside 1970 to 3000. Of its ten times, -12622780801 (1570) and -62135596800 (year 1) get -1 from mktime; the other eight invert.
  • The new region-zone case converts nine times, from the year 1 to 1950, in America/Los_Angeles, Europe/Berlin, Asia/Kolkata and America/Argentina/Buenos_Aires, with the daylight flag localtime gave and with -1.
    • With the first version, 26 of the 36 round trips are off, by exactly the amounts in jotitadev's table: +422 s in Los Angeles, -392 in Berlin, +1408 and -530 in Kolkata, -3228 and -4608 in Buenos Aires.
    • With this head, guest_time_conversion passes 5 runs of 5.
  • tools/check_conventions.py --base origin/main and git diff --check pass.

Windows 11 (WinLibs GCC 15.2.0 r7, UCRT, Release) and Ubuntu 24.04 under WSL2 (GCC 13.3.0, Release), head 0e6ad36fe merged onto main 5d9dcc42d: guest_time_conversion passes 3 runs of 3 with the change, and 3 runs of 3 with libc/src/Time.cpp as on main and the tests kept. The new commits change only macOS lines in Time.cpp. The new test case also runs on Linux and hasn't been run there yet.

Overlap: the overlap check could not compare 23 pull requests that conflict with main; none of their changes to Time.cpp touches mktime or the 400-year cycle code.

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
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4883630448 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-16T04:48:44Z. --- ### What On macOS a guest `mktime` of a time before 1900 returns -1, although `localtime` converts the same time. `mktime` hands the broken-down time to the host's `mktime`, and macOS's refuses every year before 1900. A standalone program on this Mac (`TZ=UTC-2`, 1 January at noon) gets -1 for the years 1, 1000, 1500, 1570, 1582, 1600, 1700, 1800, 1850 and 1883, and the right value from 1900 on. On macOS `mktime` now solves a local time before 2 January 1900 directly. It subtracts the offset `localtime_r` gives for a candidate time from the local fields, and repeats until the offset holds, at most four times. `localtime_r` follows the zone's history: local mean time before its first transition, then early standard offsets such as Kolkata's MMT or Buenos Aires's CMT. So `mktime(localtime(t))` returns `t` in region zones as well as fixed-offset ones. From 2 January 1900 on, the host's `mktime` still converts. The first version moved such a time 400-year cycles later, as Windows does (#4811). jotitadev found in review that this applies the zone's modern rules to the moved year, so region zones were off by the LMT difference. The second commit replaces that on macOS. The constants block is shared with Windows and keeps Windows's values (years 70 to 1100, first ordinary second one day, last 32535215999). The Windows conversion is otherwise unchanged, and Linux doesn't compile any of the changed lines. A `tm_isdst` set on a date where the zone had no daylight offset is taken as standard time. FreeBSD's `time1` would shift it by the difference between one of the zone's daylight and standard types. The `libc.md` entry for `localtime, mktime` records this. Commits: 1. The 400-year move. 2. Its debt entry. 3. The offset solve that replaces the move on macOS. 4. The region-zone test. 5. The debt entry, rewritten. ### Tested macOS 26.7.1, Apple M2, AppleClang 21.0.0, x86-64 build under Rosetta, Release. `main` does not build libc on macOS for other reasons as well (#4627 addresses them), so the test ran in a local tree of `main` ce991f1ec with #4627, #4630, #6124 and mugurc's macOS branches merged. This branch's `Time.cpp` is identical to the one tested, apart from #4627's `tm_zone` line. - `main`'s `Time.cpp`: `guest_time_conversion` aborts with `mktime did not invert localtime outside 1970 to 3000`. Of its ten times, -12622780801 (1570) and -62135596800 (year 1) get -1 from `mktime`; the other eight invert. - The new region-zone case converts nine times, from the year 1 to 1950, in America/Los_Angeles, Europe/Berlin, Asia/Kolkata and America/Argentina/Buenos_Aires, with the daylight flag `localtime` gave and with -1. - With the first version, 26 of the 36 round trips are off, by exactly the amounts in jotitadev's table: +422 s in Los Angeles, -392 in Berlin, +1408 and -530 in Kolkata, -3228 and -4608 in Buenos Aires. - With this head, `guest_time_conversion` passes 5 runs of 5. - `tools/check_conventions.py --base origin/main` and `git diff --check` pass. Windows 11 (WinLibs GCC 15.2.0 r7, UCRT, Release) and Ubuntu 24.04 under WSL2 (GCC 13.3.0, Release), head `0e6ad36fe` merged onto `main` 5d9dcc42d: `guest_time_conversion` passes 3 runs of 3 with the change, and 3 runs of 3 with `libc/src/Time.cpp` as on `main` and the tests kept. The new commits change only macOS lines in `Time.cpp`. The new test case also runs on Linux and hasn't been run there yet. Overlap: the overlap check could not compare 23 pull requests that conflict with `main`; none of their changes to `Time.cpp` touches `mktime` or the 400-year cycle code. ### 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] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-16 05:32:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T05:32:22Z.


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 6916 core/libs/tests/GuestTimeConversion.cpp L299-300

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 3987 docs/dev/debt/libc.md
PR 5021 core/libs/prx/libc/src/Time.cpp
docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6044 core/libs/tests/GuestTimeConversion.cpp
PR 6226 docs/dev/debt/libc.md
PR 6469 docs/dev/debt/libc.md
PR 6819 docs/dev/debt/libc.md
PR 6975 docs/dev/debt/libc.md
PR 7039 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7201 core/libs/prx/libc/src/Time.cpp
PR 7417 docs/dev/debt/libc.md
PR 7473 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6208825768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#issuecomment-6208825768). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-16T05:32:22Z. --- <!-- 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 6916](https://www.github.com/boykopovar/AnyPS5/pull/6916) | `core/libs/tests/GuestTimeConversion.cpp` [L299-300](https://github.com/boykopovar/AnyPS5/blob/f78675ae4d0314cc7b8316b091847327fbb2581c/core/libs/tests/GuestTimeConversion.cpp#L299-L300) | | | 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 3987](https://www.github.com/boykopovar/AnyPS5/pull/3987) | `docs/dev/debt/libc.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libc/src/Time.cpp`<br>`docs/dev/debt/libc.md` | | [PR 5303](https://www.github.com/boykopovar/AnyPS5/pull/5303) | `docs/dev/debt/libc.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestTimeConversion.cpp` | | [PR 6226](https://www.github.com/boykopovar/AnyPS5/pull/6226) | `docs/dev/debt/libc.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `docs/dev/debt/libc.md` | | [PR 6819](https://www.github.com/boykopovar/AnyPS5/pull/6819) | `docs/dev/debt/libc.md` | | [PR 6975](https://www.github.com/boykopovar/AnyPS5/pull/6975) | `docs/dev/debt/libc.md` | | [PR 7039](https://www.github.com/boykopovar/AnyPS5/pull/7039) | `docs/dev/debt/libc.md` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `docs/dev/debt/libc.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libc/src/Time.cpp` | | [PR 7417](https://www.github.com/boykopovar/AnyPS5/pull/7417) | `docs/dev/debt/libc.md` | | [PR 7473](https://www.github.com/boykopovar/AnyPS5/pull/7473) | `docs/dev/debt/libc.md` | | [PR 7715](https://www.github.com/boykopovar/AnyPS5/pull/7715) | `docs/dev/debt/libc.md` |
jotitadev commented 2026-10-16 05:36:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T05:36:06Z.

Review: COMMENTED


Checked the macOS branch against region time zones, head 0e6ad36fe, base main 5d9dcc42d.

guest_time_conversion runs CheckLocalRange under TZ=UTC-2, a fixed offset. With a region zone, which is what a Mac has by default (/etc/localtime), macOS's localtime_r gives times before the zone's first transition its LMT (or other historical) offset, while the shifted mktime here converts in the year + 400k, where the zone's modern rules apply. So mktime(localtime(t)) no longer returns t:

TZ year localtime_r offset mktime(localtime(t)) - t
UTC-2 1, 1570, 1811, 1883 +2:00 0
America/Los_Angeles 0 (Dec 31), 1569, 1811 LMT -7:52:58 +422
Europe/Berlin 1, 1570, 1811, 1883 LMT +0:53:28 -392
Asia/Kolkata 1, 1570, 1811 LMT +5:53:28 +1408
Asia/Kolkata 1883, 1900-01-01 MMT +5:21:10 -530
America/Argentina/Buenos_Aires 1569 to 1883 LMT -3:53:48 -3228
America/Argentina/Buenos_Aires 1899-12-31 CMT -4:16:48 -4608

With tm_isdst = -1 a summer date also picks up daylight time from the shifted year, though the zone had none then: 1811-07-23 gives -3178 in Los Angeles and -3992 in Berlin. The 1900-01-01 row comes from the one-day margin (firstOrdinary), which also shifts the first day of 1900.

On Windows the same shift stays consistent, as far as I know, because the CRT applies the current rules to every year. On macOS one way to keep it consistent would be to take the offset from localtime_r itself, which handles these years: start from approximate - gmtoff(approximate) and redo that once or twice until the offset holds. In the mirror below that gives 0 for every pre-1900 row in the table; the only other difference is the instant of Los Angeles's 1883 switch to PST, a local time that occurs twice. Running CheckLocalRange once more under a region zone (America/Los_Angeles, say) would cover it.

Method: a standalone mirror of the __APPLE__ path of libc_mktime_nid_postfix (same ordinary test, firstOrdinary, calendarCycles, tm_isdst carried over, then host mktime plus the cycles; civil-day helpers in place of utcSeconds and utcCalendarFields). I fed it localtime_r(t) for the times in the table. It gives 0 for every row under UTC-2, which matches your 5/5. Same numbers on arm64 and x86_64 under Rosetta. Time.cpp from this head also passes -fsyntax-only on both architectures, except the tm_zone const error at its line 85, which main has too (line 75). I did not run the full guest_time_conversion (main doesn't build libc on macOS).

Machine: Apple M2 Max, macOS 27.2 (26B5091g), Apple clang 21.0.0.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5543491976 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#pullrequestreview-5543491976). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T05:36:06Z. **Review:** COMMENTED --- Checked the macOS branch against region time zones, head `0e6ad36fe`, base `main` 5d9dcc42d. `guest_time_conversion` runs `CheckLocalRange` under `TZ=UTC-2`, a fixed offset. With a region zone, which is what a Mac has by default (`/etc/localtime`), macOS's `localtime_r` gives times before the zone's first transition its LMT (or other historical) offset, while the shifted `mktime` here converts in the year + 400k, where the zone's modern rules apply. So `mktime(localtime(t))` no longer returns `t`: | TZ | year | `localtime_r` offset | `mktime(localtime(t)) - t` | |---|---|---|---| | UTC-2 | 1, 1570, 1811, 1883 | +2:00 | 0 | | America/Los_Angeles | 0 (Dec 31), 1569, 1811 | LMT -7:52:58 | +422 | | Europe/Berlin | 1, 1570, 1811, 1883 | LMT +0:53:28 | -392 | | Asia/Kolkata | 1, 1570, 1811 | LMT +5:53:28 | +1408 | | Asia/Kolkata | 1883, 1900-01-01 | MMT +5:21:10 | -530 | | America/Argentina/Buenos_Aires | 1569 to 1883 | LMT -3:53:48 | -3228 | | America/Argentina/Buenos_Aires | 1899-12-31 | CMT -4:16:48 | -4608 | With `tm_isdst = -1` a summer date also picks up daylight time from the shifted year, though the zone had none then: 1811-07-23 gives -3178 in Los Angeles and -3992 in Berlin. The 1900-01-01 row comes from the one-day margin (`firstOrdinary`), which also shifts the first day of 1900. On Windows the same shift stays consistent, as far as I know, because the CRT applies the current rules to every year. On macOS one way to keep it consistent would be to take the offset from `localtime_r` itself, which handles these years: start from `approximate - gmtoff(approximate)` and redo that once or twice until the offset holds. In the mirror below that gives 0 for every pre-1900 row in the table; the only other difference is the instant of Los Angeles's 1883 switch to PST, a local time that occurs twice. Running `CheckLocalRange` once more under a region zone (`America/Los_Angeles`, say) would cover it. Method: a standalone mirror of the `__APPLE__` path of `libc_mktime_nid_postfix` (same `ordinary` test, `firstOrdinary`, `calendarCycles`, `tm_isdst` carried over, then host `mktime` plus the cycles; civil-day helpers in place of `utcSeconds` and `utcCalendarFields`). I fed it `localtime_r(t)` for the times in the table. It gives 0 for every row under `UTC-2`, which matches your 5/5. Same numbers on arm64 and x86_64 under Rosetta. `Time.cpp` from this head also passes `-fsyntax-only` on both architectures, except the `tm_zone` const error at its line 85, which `main` has too (line 75). I did not run the full `guest_time_conversion` (`main` doesn't build libc on macOS). Machine: Apple M2 Max, macOS 27.2 (26B5091g), Apple clang 21.0.0. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
DavidSamir commented 2026-10-16 07:33:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T07:33:44Z.


Windows and Linux results for 0e6ad36fe4, merged onto main 5d9dcc42d2:

Host Toolchain With the change Code as on main, new tests kept Restored
Windows 11 WinLibs GCC 15.2.0 r7 (UCRT), Release guest_time_conversion 3/3 3/3 1/1
Ubuntu 24.04 (WSL2) GCC 13.3.0, Release guest_time_conversion 3/3 3/3 1/1

Reverted for the middle column: libc/src/Time.cpp. The test passes either way on both hosts, as expected for a change that only alters the macOS path. The pre-1900 mktime handling shows no change on Windows and Linux.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6210485479 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#issuecomment-6210485479). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-16T07:33:44Z. --- Windows and Linux results for 0e6ad36fe4, merged onto `main` 5d9dcc42d2: | Host | Toolchain | With the change | Code as on `main`, new tests kept | Restored | |---|---|---|---|---| | Windows 11 | WinLibs GCC 15.2.0 r7 (UCRT), Release | `guest_time_conversion` 3/3 | 3/3 | 1/1 | | Ubuntu 24.04 (WSL2) | GCC 13.3.0, Release | `guest_time_conversion` 3/3 | 3/3 | 1/1 | Reverted for the middle column: `libc/src/Time.cpp`. The test passes either way on both hosts, as expected for a change that only alters the macOS path. The pre-1900 `mktime` handling shows no change on Windows and Linux. AI-assisted: yes
DavidSamir commented 2026-10-16 07:34:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T07:34:07Z.


A correction to my comment above: this change is not macOS-only. It also rewrites the Windows branch of libc_mktime_nid_postfix, using the new HOST_ORDINARY_* / HOST_FIRST_SECOND constants. On Windows they keep the old values: years 70 to 1100, and firstOrdinary = 0 + 86400, as before. So the Windows 3/3 is a check that the rewrite keeps Windows behaviour. Linux is outside the _WIN32 || __APPLE__ block, so it is unchanged.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6210491265 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#issuecomment-6210491265). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-16T07:34:07Z. --- A correction to my comment above: this change is not macOS-only. It also rewrites the Windows branch of `libc_mktime_nid_postfix`, using the new `HOST_ORDINARY_*` / `HOST_FIRST_SECOND` constants. On Windows they keep the old values: years 70 to 1100, and `firstOrdinary` = 0 + 86400, as before. So the Windows 3/3 is a check that the rewrite keeps Windows behaviour. Linux is outside the `_WIN32 || __APPLE__` block, so it is unchanged. AI-assisted: yes
DavidSamir commented 2026-10-16 09:30:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T09:30:07Z.


@jotitadev thanks, you're right, and the table holds on this Mac too.

A non-aborting copy of the new test against the first version (0e6ad36fe) gets 26 of 36 round trips off, by exactly your numbers: +422 s in Los Angeles, -392 in Berlin, +1408 and -530 in Kolkata, -3228 and -4608 in Buenos Aires.

69aa703c6 takes your approach on macOS: a local time before 2 January 1900 is solved from the offset localtime_r gives, repeated until it holds, at most four times. That also removes the 1 January 1900 row. guest_time_conversion now converts nine times, from the year 1 to 1950, through those four zones, with the daylight flag localtime gave and with -1. It passes 5 runs of 5.

A tm_isdst set where the zone had no daylight offset is taken as standard time. FreeBSD 11's time1 would shift it by the difference between one of the zone's daylight and standard types instead. That's in the debt entry.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6212485646 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#issuecomment-6212485646). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-16T09:30:07Z. --- @jotitadev thanks, you're right, and the table holds on this Mac too. A non-aborting copy of the new test against the first version (`0e6ad36fe`) gets 26 of 36 round trips off, by exactly your numbers: +422 s in Los Angeles, -392 in Berlin, +1408 and -530 in Kolkata, -3228 and -4608 in Buenos Aires. `69aa703c6` takes your approach on macOS: a local time before 2 January 1900 is solved from the offset `localtime_r` gives, repeated until it holds, at most four times. That also removes the 1 January 1900 row. `guest_time_conversion` now converts nine times, from the year 1 to 1950, through those four zones, with the daylight flag `localtime` gave and with -1. It passes 5 runs of 5. A `tm_isdst` set where the zone had no daylight offset is taken as standard time. FreeBSD 11's `time1` would shift it by the difference between one of the zone's daylight and standard types instead. That's in the debt entry. AI-assisted: yes
MarcZX10 commented 2026-10-16 18:02:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T18:02:46Z.


Integration check: issue #6910 has a ready change that makes local-time conversions apply TZ from the guest environment. In a combined tree, CheckRegionZones here currently sets the host TZ directly with setenv, while the guest environment remains at the test program’s UTC-2; the next conversion would restore UTC-2 and the region-zone round trips would no longer exercise those regions. Could we let this PR land first, then I can carry #6910 with its combined test setting the guest TZ through setenv_nid_postfix? If you prefer a different integration order, I can adapt around that.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6221654096 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#issuecomment-6221654096). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T18:02:46Z. --- Integration check: issue #6910 has a ready change that makes local-time conversions apply `TZ` from the guest environment. In a combined tree, `CheckRegionZones` here currently sets the host `TZ` directly with `setenv`, while the guest environment remains at the test program’s `UTC-2`; the next conversion would restore `UTC-2` and the region-zone round trips would no longer exercise those regions. Could we let this PR land first, then I can carry #6910 with its combined test setting the guest `TZ` through `setenv_nid_postfix`? If you prefer a different integration order, I can adapt around that.
MarcZX10 commented 2026-10-16 18:16:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T18:16:17Z.


I opened #6916 carrying the guest-TZ change. The PR body and its libc debt note both call out the CheckRegionZones interaction: after guest TZ has been set, the test’s host-side setenv can be overwritten by the next guest conversion. Could you update that region-zone test to set the guest TZ, or otherwise verify the combined test? I will keep the integration requirement visible and will not treat the two changes as independently mergeable without the combined test passing.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6221894335 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#issuecomment-6221894335). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T18:16:17Z. --- I opened #6916 carrying the guest-TZ change. The PR body and its libc debt note both call out the `CheckRegionZones` interaction: after guest TZ has been set, the test’s host-side `setenv` can be overwritten by the next guest conversion. Could you update that region-zone test to set the guest TZ, or otherwise verify the combined test? I will keep the integration requirement visible and will not treat the two changes as independently mergeable without the combined test passing.
MarcZX10 commented 2026-10-16 18:31:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T18:31:55Z.


Correction to my earlier integration warning: I composed #6686 head 69aa703c6 and #6916 in a temporary tree. After resolving only the overlapping test-file edits while retaining both sets of checks, guest_time_conversion passed. I kept #6686’s original host-side setenv("TZ", zone, 1) and added a temporary assertion that the 2024-01-01 conversion had the expected offsets for Los Angeles, Berlin, Kolkata and Buenos Aires; all four passed. applyGuestZone() does not overwrite a host-side zone change when the guest TZ snapshot itself is unchanged. My earlier warning and request to change CheckRegionZones were mistaken; no change to your test is needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6222162871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#issuecomment-6222162871). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T18:31:55Z. --- Correction to my earlier integration warning: I composed #6686 head `69aa703c6` and #6916 in a temporary tree. After resolving only the overlapping test-file edits while retaining both sets of checks, `guest_time_conversion` passed. I kept #6686’s original host-side `setenv("TZ", zone, 1)` and added a temporary assertion that the 2024-01-01 conversion had the expected offsets for Los Angeles, Berlin, Kolkata and Buenos Aires; all four passed. `applyGuestZone()` does not overwrite a host-side zone change when the guest `TZ` snapshot itself is unchanged. My earlier warning and request to change `CheckRegionZones` were mistaken; no change to your test is needed.
adriadam10 commented 2026-10-19 09:01:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T09:01:35Z.


Checked the macOS offset solve against the Windows branch (constants and firstOrdinary unchanged there, Linux doesn't compile the changed lines), the region-zone round-trip test and the libc.md debt entry. Merging through the queue; its Linux build covers the new test case.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6263572771 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6686#issuecomment-6263572771). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T09:01:35Z. --- Checked the macOS offset solve against the Windows branch (constants and `firstOrdinary` unchanged there, Linux doesn't compile the changed lines), the region-zone round-trip test and the `libc.md` debt entry. Merging through the queue; its Linux build covers the new test case.
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!6686
No description provided.