Skip to content

fix(rtc): parse RFC 2822, RFC 850 and asctime text like the console - #1399

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
hugodearaujo:fix/rtc-parse-datetime-rfc2822-hardware
Oct 8, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
hugodearaujo:fix/rtc-parse-datetime-rfc2822-hardware

Conversation

@hugodearaujo

Copy link
Copy Markdown
Contributor

What

Stacked on #1398, which is itself stacked on #1397: this branch also carries their commits, and only the last commit is new here.

In #816 the open question was which shapes the console's sceRtcParseDateTime accepts, so returning SCE_RTC_ERROR_BAD_PARSE for anything else was left for hardware evidence. This PR is that evidence. I measured 1174 inputs on a PS5 (firmware 13.60) by calling the real libSceRtc.sprx export through dlopen from a homebrew payload, with the tick preset to 0xdeadbeefcafebabe. The table and the probe source are in the comments on #1397. With this branch, a host harness gets the same return code and tick as the console for all 1174. 400 of them were random mutations of valid strings that I measured only after the implementation was frozen, and all 400 matched with no changes.

Grammar measured after leading spaces and tabs (a digit there goes to the RFC 3339 path from #1398):

  • Weekday is required. It can be the full name or three letters, in any case, and it is never checked against the date. An optional , must follow it directly (Thu , and Thu,, are BAD_PARSE), then any number of spaces and tabs. A digit next means RFC 2822/850; a letter means asctime.
  • RFC 2822 / RFC 850: the day has 1–2 digits. Then ' ' or '-', a month (full name or three letters, any case, nothing else: Sept, Jun., Janu are BAD_PARSE), ' ' or '-' again, and a year of exactly 2 or 4 digits (00–49 → 20xx, 50–99 → 19xx). Then one space and H:M[:S] with 1–2 digit fields; an hour above 25 is BAD_PARSE.
    • After the seconds, one space starts a zone. Two spaces, a tab, or other text means the zone is ignored, and so is the rest of the string. Without seconds the zone is ignored too (12:34 EST is 12:34 UTC).
    • Zone: +/- followed by four digits is applied as HHMM with no range check (+9999, -12345 → 99:99, 12:34). Anything shorter (+01:30, +1, +) gives offset 0.
    • A name is matched case-insensitively against the console's table, as a prefix (ESTERN = EST, PST8PDT = PST). Before that check, the console takes the zone as UT whenever the first character is an upper-case U or the second is an upper-case T (ET, xT, Ux → 0, while ut is the military letter u, −7h).
    • Any other letter uses the console's military table, which is off by one hour against RFC 822: A–I = 0…+8, K–M = +10…+12, N–Y = 0…−11, Z = 0, J = BAD_PARSE. A name that is not in the table uses its first letter (HST = H = +7h, MSK = M).
    • Any other character in the zone position is BAD_PARSE.
  • asctime: a month (full name or three letters), one space, a day as D, D or DD, one space, then H:M:S (all three required), one space, and exactly four year digits. Anything after that, including a zone, is ignored.
  • Results: text that does not fit this grammar is BAD_PARSE, and the tick is left untouched. A date or time that parses but is out of range (30 Feb, 25:00, 12:99, year 0) returns 0 without writing the tick, but the offset is still subtracted from the old tick, exactly like the 60th second in sceRtcParseRFC3339 (fix(rtc): match sceRtcParseRFC3339 to the console #1397). Both go through storeParsedTick.

The zone table holds the 47 names that the console mapped to their own offset among the 284 distinct zone tokens I measured. Its values are the console's, even where they differ from the real zones: NST is −2:30, FWT is +2. The TechnicalDebt entry now records only what is still unknown: a name that I did not measure could be in the console's table, and it would get its first letter's offset here instead.

The part of the reviewer's notes on #816 that the console contradicts: it does apply +9999, and it accepts 29 Feb 2024 ... only with a weekday.

Title evidence, stated plainly: the only evidence for this function is #516's statement that The Last of Us Part I needs sceRtcParseDateTime. #516 was merged on that statement alone, with no title ID and no log line. The Propagation: Paradise Hotel dump (PPSA15878) that backs #1397 does not use this function, only sceRtcParseRFC3339. The "title ID and the log line where it stops on main" bar was set for new library functions, and this PR corrects one that is already merged. It may still apply, so I'm flagging it here.

Tested

  • PS5 firmware 13.60: 1174 inputs, all with the same return code and tick on this branch as on the console, for both sceRtcParseDateTime and sceRtcParseRFC3339. Every string the test uses was also run on the console.
  • Linux: build, libs, full CTest 408/408.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: build, libs, CTest 0 failed of 404 (GPU execution tests skipped, the VM has no GPU).
  • Mutation check: 27 mutations of the grammar each make guest_rtc fail. They cover the weekday and month name forms, the comma and whitespace rules, the separators, the year digit count and the 2-digit pivot, the hour limit, the zone and seconds rules, the UT check, the military formula, table entries, and the asctime day and year rules.

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: fix(rtc): parse ISO text in sceRtcParseDateTime by the RFC 3339 rules #1398
  • AI-assisted: yes

🤖 Generated with Claude Code

hugodearaujo and others added 3 commits October 7, 2026 19:04
Measured on a PS5 (firmware 13.60) through dlopen of libSceRtc.sprx:
an empty fraction is accepted, any digits past the sixth are dropped,
text after the zone is ignored, the offset is applied without a range
check, and a 60th second returns 0 with the tick only shifted by the
offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a PS5 (firmware 13.60) every input that starts with a digit gets the
same result and tick from sceRtcParseDateTime as from
sceRtcParseRFC3339, except that leading spaces and tabs are skipped
first. A string without a zone, or with a space instead of T, is a
parse error rather than UTC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured on a PS5 (firmware 13.60) through dlopen of libSceRtc.sprx.
The weekday is required in any case or length, month names may be
full, RFC 2822 and RFC 850 share one lenient grammar with 2-digit years
split at 50, and the asctime zone is ignored. Zones come from a name
table, a military letter, or +HHMM without a range check. Text the
console rejects returns a parse error with the tick untouched, and an
invalid calendar date returns 0 with only the offset applied to the
tick, as the console does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Progress report (df16c4c → a156104)

📈 System libraries: 86.18% (+0.04%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceRtc sceRtcParseDateTime

@hugodearaujo

Copy link
Copy Markdown
Contributor Author

About the overlap report: #1253, #1306 and #1314 are not dependencies. Each of them inserts a TechnicalDebt line right after s_setkill, which is directly above the sceRtcParseDateTime entry, and this PR has to rewrite that entry (it still says that ISO text without a zone is read as UTC). Git treats the two edits as a conflict only because the lines are adjacent. Code and tests do not overlap. Whichever lands first, I'll rebase the other side. The three shader PRs also overlap with each other at the same spot.

popcoder565 added a commit to popcoder565/AnyPS5 that referenced this pull request Oct 8, 2026
boykopovar#1398 and boykopovar#1399 both rewrite the sceRtcParseDateTime entry that the s_sethalt entry followed. It now follows the libSceAudio3d entries, which no open pull request edits, so either can merge first without a conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adriadam10 pushed a commit to popcoder565/AnyPS5 that referenced this pull request Oct 8, 2026
boykopovar#1398 and boykopovar#1399 both rewrite the sceRtcParseDateTime entry that the s_sethalt entry followed. It now follows the libSceAudio3d entries, which no open pull request edits, so either can merge first without a conflict.

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

Copy link
Copy Markdown
Collaborator

Replayed the 1174 console inputs from the #1397 tables (sceRtcParseDateTime columns) against the parser code from this branch: same return code and tick for all of them. guest_rtc fails with the Export.cpp change reverted, full ctest 455/455 green, CI green (linux, windows, conventions). TechnicalDebt entry is in "Unknown function info" and states what is still unmeasured; merging.

@adriadam10
adriadam10 merged commit c68c757 into boykopovar:main Oct 8, 2026
4 checks passed
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.

2 participants