libRtc: implement sceRtcFormatRFC2822 and the local-time formatters #1184
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1184
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1184"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@overlordxrz-source on GitHub · 2026-10-08 02:31 UTC · original
overlordxrz-source:libs/rtc-rfc2822→main· +298 −18 · 3 files · 3 commits · opensceRtcFormatRFC2822(eiuobaF-hK4),sceRtcFormatRFC2822LocalTime(AxHBk3eat04) andsceRtcFormatRFC3339LocalTime(DwuHIlLGW8I) are not registered. A game that calls one of them gets the unresolved-import stub, which returns 0 and leaves the caller's buffer untouched. The game then reads whatever bytes were already in that buffer as a date string.This adds all three next to the existing
sceRtcFormatRFC3339:RtcFormatRFC3339into a small helper, and both formatters use itsceRtcFormatRFC2822writesWed, 07 Oct 2026 21:43:05 -0400, which is 31 characters plus the terminator. It stays inside the same 32-byte boundsceRtcFormatRFC3339already uses.LocalTimevariants use a zero offset.RtcConvertUtcToLocalTimedeliberately keeps RTC local time equal to UTC, and these follow it, so the string still names the right instant.RTC_ERROR_INVALID_POINTERfor a null buffer. A null tick formats the current time. An offset that moves the tick outside 0001..9999, or that would wrap it, returnsRTC_ERROR_INVALID_VALUEwithout writing.INT_MINis no longer undefined behaviourEvidence
Unresolved import stub called [0]: ... symbol=AxHBk3eat04[Rtc_v1][Rtc_v1.1][Func] ... eboot.bin, logged twice in a rowsceRtcFormatRFC2822orsceRtcFormatRFC3339LocalTimein the issue logs I have. I added them because they share the code with the one the game calls, and each is one line inInitRtc_1. I can drop them if you'd rather keep this to the one that's called.I'm not claiming this changes how far TMNT gets. It only means the game gets a real date string.
Testing
New
tests/RtcFormatTests.cpp(rtc_format_tests, added tokyty_testsand ctest). It includeslibRtc.cppthe wayCesTests.cppincludeslibCes.cpp, then resolves the four formatters by NID throughInitRtc_1. It checks:0001-01-01and9999-12-31 23:59:59LocalTimevariants match offset 0What I ran (my machine is aarch64 Linux, no Vulkan):
src/common/dateTime.cppand stubs forDbgExit): all checks pass, including under-fsanitize=undefined. Against the oldlibRtc.cppit fails on the three missing NIDs.libRtc.cppand the test forx86_64-linux-gnuat-Wall -Wextra. The changed lines add no warnings.src/.clang-format(clang-format 23.1.3)I didn't run the CMake target itself, and I didn't build on Windows or macOS.
AI assistance
An AI assistant helped me find the missing export in the issue logs, write the change and the test, and run the builds above. I reviewed the code and the results.
@coderabbitai[bot] on GitHub · 2026-10-08 02:35 UTC · original · edited 2026-10-08 15:44 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
f7645420-d3f7-4262-b644-f637efa279c5📥 Commits
Reviewing files that changed from the base of the PR and between
810593da94and4d22fc111f.📒 Files selected for processing (2)
src/libs/libRtc.cpptests/RtcFormatTests.cpp🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough
RTC date-time formatting now applies time-zone offsets with underflow and overflow checks. RFC 2822 and local-time formatters are added and registered. A new test executable checks formatter output, return codes, and buffer boundaries. CMake builds and registers the test.
Priority: ⬇️ Low
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
4d22fThe checked formatter and test-integration concerns do not block merging.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -355,2 +443,4 @@return RtcFormatRFC2822(date_time, utc, RTC_LOCAL_TIME_ZONE_MINUTES);}@coderabbitai[bot] on GitHub · 2026-10-08 02:35 UTC · original · edited 2026-10-08 02:49 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7846
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11579
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8410
Check the RFC2822 formatted length before returning
OK.The exported formatter accepts
time_zone_minutesas anint, and no range check rejects6000. For a normal date,GetFormatDateTimeadds360000000000ticks and succeeds. The format then needs 32 characters because6000minutes produces+10000. A 32-byte buffer holds only 31 characters plus the terminator, sosnprintftruncates the result while the function returnsOK.Suggested fix
✅ Confirmed as addressed by @overlordxrz-source
@coderabbitai[bot] on GitHub · 2026-10-08 02:35 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
fe85f7a9-655a-4c34-924a-5ee8f4b87b9d📥 Commits
Reviewing files that changed from the base of the PR and between
5a8808086aand07b1b7f1d6.📒 Files selected for processing (3)
CMakeLists.txtsrc/libs/libRtc.cpptests/RtcFormatTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
@ -355,2 +443,4 @@return RtcFormatRFC2822(date_time, utc, RTC_LOCAL_TIME_ZONE_MINUTES);}@overlordxrz-source on GitHub · 2026-10-08 02:48 UTC · original
Good catch, thanks. Fixed in "libRtc: reject RFC formatter output that does not fit in 32 bytes".
Both formatters now build the string in a local 32-byte buffer, check the snprintf result, and copy it to the guest buffer only when it fits. Otherwise they return RTC_ERROR_INVALID_VALUE and write nothing. sceRtcFormatRFC3339 had the same unchecked call, and its zone suffix was also cut off silently from 1000 hours up, so it gets the same check. The LocalTime variants share this code.
The tests now cover the longest offsets that still fit (+/-9959 for RFC 2822, +999:59 for RFC 3339). They also check that 6000 and 60000 minutes return INVALID_VALUE and leave the buffer untouched.
@ -355,2 +443,4 @@return RtcFormatRFC2822(date_time, utc, RTC_LOCAL_TIME_ZONE_MINUTES);}@coderabbitai[bot] on GitHub · 2026-10-08 02:49 UTC · original
@overlordxrz-sourceThanks for the fix. The updated code checks the formatted length before copying to the guest buffer. Both formatters now returnRTC_ERROR_INVALID_VALUEwithout writing when the output does not fit. This addresses the finding.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@ -346,0 +384,4 @@static_cast<int>(minutes % 60));if (len < 0 || static_cast<size_t>(len) >= sizeof(zone)) {return RTC_ERROR_INVALID_VALUE;}@coderabbitai[bot] on GitHub · 2026-10-08 02:51 UTC · original · edited 2026-10-08 15:43 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reject offsets outside the RFC 3339 hour range. A 24-hour offset fits the zone buffer, but RFC 3339 permits only
00–23for offset hours. The current formatter returns success for+24:00, and the new test expects success for+999:59. Strict consumers can reject both timestamps. (rfc-editor.org)src/libs/libRtc.cpp#L377-L382: reject offsets of 24 hours or more before formatting.tests/RtcFormatTests.cpp#L138-L143: expectRTC_ERROR_INVALID_VALUEand an untouched buffer for out-of-range offsets.📍 Affects 2 files
src/libs/libRtc.cpp#L377-L382(this comment)tests/RtcFormatTests.cpp#L138-L143✅ Confirmed as addressed by @overlordxrz-source
@coderabbitai[bot] on GitHub · 2026-10-08 02:51 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
14771b99-c4e6-41e5-addc-7b3fb4154383📥 Commits
Reviewing files that changed from the base of the PR and between
07b1b7f1d6and810593da94.📒 Files selected for processing (2)
src/libs/libRtc.cpptests/RtcFormatTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.
@ -346,0 +384,4 @@static_cast<int>(minutes % 60));if (len < 0 || static_cast<size_t>(len) >= sizeof(zone)) {return RTC_ERROR_INVALID_VALUE;}@overlordxrz-source on GitHub · 2026-10-08 15:43 UTC · original
Fixed in "libRtc: reject RFC 3339 offsets of 24 hours or more".
sceRtcFormatRFC3339 (and the LocalTime variant, which shares the code) now returns RTC_ERROR_INVALID_VALUE for an offset of 24 hours or more, before writing anything. The tests now accept +/-23:59 and expect INVALID_VALUE with an untouched buffer for +/-24:00 and 60000 minutes. With the old code the new checks fail; with the fix the test passes natively. I haven't checked what the console's own formatter does with such offsets.
@ -346,0 +384,4 @@static_cast<int>(minutes % 60));if (len < 0 || static_cast<size_t>(len) >= sizeof(zone)) {return RTC_ERROR_INVALID_VALUE;}@coderabbitai[bot] on GitHub · 2026-10-08 15:43 UTC · original
@overlordxrz-sourceThanks for the fix. The supplied code rejects offsets of ±24 hours or more before writing to the output buffer. Your reported tests cover ±23:59, ±24:00, and 60000 minutes, including unchanged buffers on rejection.Console behavior remains unverified, but this addresses the RFC 3339 compliance finding.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.