Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:feat/rtc-parse-datetime-rfc2822
Oct 6, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:feat/rtc-parse-datetime-rfc2822

Conversation

@adriadam10

Copy link
Copy Markdown
Collaborator

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

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 5, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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.

Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator Author

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

@adriadam10
adriadam10 force-pushed the feat/rtc-parse-datetime-rfc2822 branch from d34c315 to 4e5a1fe Compare October 6, 2026 05:16
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

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

@oneandonlydean
oneandonlydean merged commit dd9b957 into boykopovar:main Oct 6, 2026
3 checks passed
@ebosido444-ai

Copy link
Copy Markdown
Contributor

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.

@adriadam10
adriadam10 deleted the feat/rtc-parse-datetime-rfc2822 branch October 6, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants