feat(rtc): parse RFC 2822 and asctime strings in sceRtcParseDateTime #782

Merged
adriadam10 merged 1 commit from upstream-pr/782 into main 2026-10-06 09:31:17 +00:00
adriadam10 commented 2026-10-05 23:37:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T23:37:32Z.


What

sceRtcParseDateTime (#516) parses the ISO 8601 / RFC 3339 shape and throws for anything else. This adds the two other shapes shadPS4's sceRtcParseDateTime (rtc.cpp) parses, the only reference with a body (KytyPS5 has none, fpPS4 is a TODO):

  • RFC 2822: Ddd, DD Mon YYYY HH:MM:SS, optionally followed by ±HHMM or GMT.
  • asctime: Ddd Mon DD HH:MM:SS YYYY, with the day zero- or space-padded.

Behaviour that differs from shadPS4, or that it doesn't specify:

  • Offset sign: shadPS4 adds a +HHMM offset to get UTC, in both its RFC 2822 and RFC 3339 parsers, but its own sceRtcFormatRFC2822/FormatRFC3339 also add the offset to go from UTC to local time, so its parse and format don't round-trip. Here the offset is subtracted, like our sceRtcParseRFC3339 and RFC 2822 itself.
  • Strict parsing: shadPS4 reads fixed positions with std::stoi and ignores anything else in the string. Here every separator is checked, and so are the month and weekday names. Any other suffix (such as PST, +01:30, a trailing \n or extra characters) throws through NotImplemented_nid_no_patch, as the ISO path already does. For GMT shadPS4 applies no offset, and this PR does the same.
  • Errors: range errors come from the existing validate (for example, 30 Feb returns SCE_RTC_ERROR_INVALID_DAY). The weekday name is not checked against the date, and shadPS4 doesn't check it either.

The ISO path's behaviour is unchanged. It was moved into parseIsoDateTime so all three shapes share the validation, the tick conversion and the throw. The TechnicalDebt line now lists the accepted shapes and the sign choice.

Tested

  • Linux, GCC Release: guest_rtc passes. The full build, the libs target and ctest -R 'guest_|rtc' (105 tests) all pass.
  • The new rows cover both shapes at UTC, with GMT, with +0130 and -0130, at the epoch, with a space-padded day and with an invalid day, plus 8 shapes that must throw. The expected values were checked with Python's email.utils.parsedate_to_datetime/strptime. On main the test fails because the RFC 2822 rows throw.
  • Negative checks, each of which makes the test fail: flipping the offset sign, dropping GMT, an off-by-one month, no space-padded day, dropping the asctime or RFC 2822 path, no offset range check, and not checking the weekday.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4752080425 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/782). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-05T23:37:32Z. --- ### What `sceRtcParseDateTime` (#516) parses the ISO 8601 / RFC 3339 shape and throws for anything else. This adds the two other shapes shadPS4's `sceRtcParseDateTime` (`rtc.cpp`) parses, the only reference with a body (KytyPS5 has none, fpPS4 is a TODO): - RFC 2822: `Ddd, DD Mon YYYY HH:MM:SS`, optionally followed by ` ±HHMM` or ` GMT`. - asctime: `Ddd Mon DD HH:MM:SS YYYY`, with the day zero- or space-padded. Behaviour that differs from shadPS4, or that it doesn't specify: - **Offset sign:** shadPS4 *adds* a `+HHMM` offset to get UTC, in both its RFC 2822 and RFC 3339 parsers, but its own `sceRtcFormatRFC2822`/`FormatRFC3339` also add the offset to go from UTC to local time, so its parse and format don't round-trip. Here the offset is subtracted, like our `sceRtcParseRFC3339` and RFC 2822 itself. - **Strict parsing:** shadPS4 reads fixed positions with `std::stoi` and ignores anything else in the string. Here every separator is checked, and so are the month and weekday names. Any other suffix (such as `PST`, `+01:30`, a trailing `\n` or extra characters) throws through `NotImplemented_nid_no_patch`, as the ISO path already does. For ` GMT` shadPS4 applies no offset, and this PR does the same. - **Errors:** range errors come from the existing `validate` (for example, 30 Feb returns `SCE_RTC_ERROR_INVALID_DAY`). The weekday name is not checked against the date, and shadPS4 doesn't check it either. The ISO path's behaviour is unchanged. It was moved into `parseIsoDateTime` so all three shapes share the validation, the tick conversion and the throw. The TechnicalDebt line now lists the accepted shapes and the sign choice. ### Tested - Linux, GCC Release: `guest_rtc` passes. The full build, the `libs` target and `ctest -R 'guest_|rtc'` (105 tests) all pass. - The new rows cover both shapes at UTC, with `GMT`, with `+0130` and `-0130`, at the epoch, with a space-padded day and with an invalid day, plus 8 shapes that must throw. The expected values were checked with Python's `email.utils.parsedate_to_datetime`/`strptime`. On `main` the test fails because the RFC 2822 rows throw. - Negative checks, each of which makes the test fail: flipping the offset sign, dropping `GMT`, an off-by-one month, no space-padded day, dropping the asctime or RFC 2822 path, no offset range check, and not checking the weekday. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
oneandonlydean commented 2026-10-06 01:12:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T01:12:43Z.


Thanks, this looks right to me. The three parsers share the validation and tick conversion, the ISO path behaves as before, every separator and name is checked, and subtracting the ±HHMM offset matches sceRtcParseRFC3339 and RFC 2822 (and fixes shadPS4's round-trip problem rather than copying it). The new rows fail on main, as you say.

It needs a one-line rebase now: docs/dev/TechnicalDebt.md conflicts with current main, because #740 added the sceAudio3dPortOpen line directly under the sceRtcParseDateTime line you rewrite. Keeping your version of the Rtc line and main's Audio3d line after it resolves it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6007249024 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/782#issuecomment-6007249024). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-06T01:12:43Z. --- Thanks, this looks right to me. The three parsers share the validation and tick conversion, the ISO path behaves as before, every separator and name is checked, and subtracting the `±HHMM` offset matches `sceRtcParseRFC3339` and RFC 2822 (and fixes shadPS4's round-trip problem rather than copying it). The new rows fail on `main`, as you say. It needs a one-line rebase now: `docs/dev/TechnicalDebt.md` conflicts with current `main`, because #740 added the `sceAudio3dPortOpen` line directly under the `sceRtcParseDateTime` line you rewrite. Keeping your version of the Rtc line and main's Audio3d line after it resolves it.
adriadam10 commented 2026-10-06 05:16:16 +00:00 (Migrated from github.com)

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


Rebased on current main: kept the rewritten sceRtcParseDateTime TechnicalDebt line with the sceAudio3dPortOpen line from #740 right after it. guest_rtc passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6009835837 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/782#issuecomment-6009835837). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-06T05:16:16Z. --- Rebased on current `main`: kept the rewritten `sceRtcParseDateTime` TechnicalDebt line with the `sceAudio3dPortOpen` line from #740 right after it. `guest_rtc` passes.
github-actions[bot] commented 2026-10-06 07:35:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T07:35:52Z.


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
#821 docs/dev/TechnicalDebt.md L36
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6011630545 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/782#issuecomment-6011630545). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-06T07:35:52Z. --- <!-- 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 | |---|---|---|---| | #821 | `docs/dev/TechnicalDebt.md` [L36](https://github.com/boykopovar/AnyPS5/blob/25f76f27d94c89cb4e70f06e100f1e6f788c61f1/docs/dev/TechnicalDebt.md#L36) | | |
ebosido444-ai commented 2026-10-06 09:41:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-06T09:41:56Z.


Dropping a test idea here per oneandonlydean's suggestion (from the #816 review): a cross-check row tying the two parsers together — sceRtcParseDateTime("Tue, 01 Jul 2003 10:52:37 +0200") should equal sceRtcParseRFC3339("2003-07-01T08:52:37Z") (same instant, independent paths; the reference via ParseRFC3339 keeps it honest). A couple of rows like that in GuestRtc would lock the timezone-offset direction against exactly the class of slip I made in #816's TechnicalDebt line. Feel free to take or ignore.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6013578517 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/782#issuecomment-6013578517). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-06T09:41:56Z. --- Dropping a test idea here per oneandonlydean's suggestion (from the #816 review): a cross-check row tying the two parsers together — `sceRtcParseDateTime("Tue, 01 Jul 2003 10:52:37 +0200")` should equal `sceRtcParseRFC3339("2003-07-01T08:52:37Z")` (same instant, independent paths; the reference via ParseRFC3339 keeps it honest). A couple of rows like that in GuestRtc would lock the timezone-offset direction against exactly the class of slip I made in #816's TechnicalDebt line. Feel free to take or ignore.
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!782
No description provided.