fix(libc): format strftime and asctime as FreeBSD 11 does #4543
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4543"
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 coltken95 on 2026-10-12T15:15:30Z.
What
strftime(libc) handed most conversions to the host'sstrftime, which differs from FreeBSD 11's:EandOwith conversions glibc does not pair them with were printed literally (%Ea,%OX,%OD,%OF).%Yprinted899and-1where FreeBSD prints0899and-001;%C,%y,%G,%g,%F,%c,%Dand%vfollowed.%Iof hour 100 gave88(FreeBSD04),%uof weekday 8 gave1(FreeBSD8), and%Wdiffered.%+and%vleft them unexpanded (%_+printed literally); on Windows the%-,%_and%0flags printed nothing.asctimeprinted the year as a plain number; FreeBSD formats it with%Y(0899) and sets years longer than four digits apart (12345).strftimenow follows FreeBSD 11 strftime.c with the C locale on both hosts, andasctimefollows asctime.c.%skeeps the guest's local-timemktime. The TechnicalDebt entry is rewritten; the Windows gaps it listed are gone, and that the console's libc uses this code is recorded as not measured.Tested
Linux (Ubuntu 24.04, GCC 13.3). Compared against FreeBSD 11
strftime.candasctime.ccompiled as references: 500000 random cases (every conversion, padding flag,E/Omodifier and unknown character, out-of-range fields, years from -2147481748 to 2147485547, short buffers), in UTC and America/New_York; no differences. Newguest_strftimetest (one case per difference above, short buffer, null format, bothasctimelayouts); it fails before this change and passes after. All 44 libcguest_*tests registered in this configuration, plusguest_crtandguest_rtc, pass. Windows not built locally (no MinGW toolchain available). No title tested.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)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T05:21:19Z.
Needs a rebase:
docs/dev/debt/libc.mdconflicts with the entries merged today (#4733, #4811). The code merges cleanly.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T06:13:13Z.
Tested on Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: this PR merged onto
mainea2bbefb2(the only merge conflict isdocs/dev/debt/libc.md; I took this PR's side for the build).guest_strftime(this PR),guest_time_conversionandguest_mktimepass.strftimefor 2009-02-07 03:04:05 UTC (single-digit day, hour, minute, second, month, week):%-,%_and%0on each of%d %e %H %I %j %k %l %M %m %S %U %W %V, the flag withE/Obefore and after it (%-Ed,%_Od,%E-e,%O0k), the flag on conversions that ignore it (%-y,%_Y,%0C,%-D,%_T,%0F,%-a,%_b,%0p,%-n,%_t),%_vand%0+. All 9 format strings (about 60 conversions) give the FreeBSD result with this PR.mainfail:strftime(buf, n, "%-d|%-e|...", &tm)returns 0 with an empty string on Windows, so the Windows part of the description is reproduced and fixed.Not tested: Linux, a console, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T10:19:02Z.
Rebased onto
77b9f7270. Thedocs/dev/debt/libc.mdconflicts are resolved: #4811'slocaltime, mktimeentry is kept as merged, and this PR'sstrftime and asctimeentry replaces the oldstrftimeone, followed by #4226'swcsftimeentry.wcsftimenow runs on thisstrftime; all 51 libcguest_*tests pass on Linux, includingguest_strftimeand thewcsftimecases.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T10:28:32Z.
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.
main)core/libs/prx/libc/src/Time.cppL237