fix(libc): format strftime and asctime as the PS5 libc does #5540
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5540"
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?
Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-13T23:16:01Z.
What
strftimeandasctimefollowed FreeBSD 11. A PS5'slibSceLibcInternal.sprx(firmware 13.60) has a C99 formatter with different rules, and 118 of 175 format and date pairs gave a different result. I measured the console's functions from a payload, over about 9,200 formats and broken-down times, then rewrote both functions to its rules.main%k,%l,%s,%v,%+,%P, flags such as%-d,%_d,%5Y,%^a)%k%EandO%Eais%a); before an unknown one,%E]gives%]%ztm_isdstis positive fromtm_year86, andtm_gmtoffignored:-0300heretm_gmtoff:+0100%Ztm_zonetm_hour100 is00,tm_year8100 is0000); a weekday or month outside its table is an empty name, the first name when negative?namesasctime%cand a line feed (" Jan 2 03:04:05 2025\n"fortm_wday7)"??? ..."names, five-digit yearsCommon formats with valid dates (
%c,%Y-%m-%d,%H:%M:%S, week numbers of real dates) were already right and stay unchanged.Two console results are not reproduced and are listed in the debt:
tm_yearbelow 0, the console's%zcopies unrelated memory (text from its error-message table, up to the buffer size);tm_wdayortm_ydayoutside their range, its ISO week (%G,%g,%V) differs.A format that ends in
%Eor%Omakes the console loop forever, so I could only measure it with a watchdog thread. AnyPS5 writes the two characters and returns instead.Tested
strftimeandasctimeby NID inlibSceLibcInternal.sprx:%c,%Ecand%Ocover printable characters;tmfield swept out of range, over all conversions andasctime;%zfrom 1960 to 2040 with and without daylight saving;tm_wdayandtm_yday, the 931 ISO cases all match.guest_strftimeandguest_time_conversionnow hold the console's results;guest_strftimefails with the oldTime.cpp.agc_driver_tessellationsegfaults the same way onmain.mainand the 13 open PRs that touchTime.cpp, its tests ordocs/dev/debt/libc.md.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T04:42:32Z.
Closing: no title is known to reach this. With the queue at 480+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed