fix(libc): support the FreeBSD strftime conversions %k %l %s %v and %+ on Windows #2702
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2702"
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 husseinkad on 2026-10-10T11:33:58Z.
What
The guest
strftimepasses the format to the Windows CRT, which does not know%k,%l,%s,%vand%+. The call returned 0 and wrote nothing. FreeBSD'sstrftime(3)documents all five:%kis the hour (24-hour clock), blank-padded;%lthe hour (12-hour clock), blank-padded%sis the seconds since the Epoch:mktimeof the broken-down time in the local time zone, as in FreeBSD 9 and 11 (current FreeBSD usestm_gmtoff),-1if it cannot be represented%vis%e-%b-%Y%+is%a %b %e %H:%M:%S %Z %Yin the C locale, with%Ztaken from the broken-down time'stm_zone(ortzname[tm_isdst != 0]when it is null)Time.cppexpands these five before calling the hoststrftime.EandOmodifiers in front of them are accepted as in FreeBSD's_fmt();%%kstays literal, and%E%/%O%are copied as one unit so the next character stays literal, as the host and FreeBSD treat them. A format that contains none of the five goes to the host untouched. The caller'stmis never modified (%sworks on a copy). What is still different (padding flags on the new conversions, an unknown conversion or a trailing lone%, a doubled modifier,%P, a standalone%z/%Z) is recorded in TechnicalDebt.Tested
Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release:
guest_time_conversion(fixed epoch 1700000000,TZ=UTC-2) covers all five conversions, hours 0/12/13 and single-digit padding, exact fit and one byte short,%%k/%%%k,%E%kand friends, theE/Oforms, atm_zonethat differs from the host's zone name, a nulltm_zonewithtm_isdst0 and 1, and%sagainstmktime. It fails withTime.cppreverted and passes with the change;ctest -R guest_timepasses.main'sTime.cpp, built from the same sources: about 3.0M format/tm/size cases (7 TZ settings, hours -12 to INT_MAX,tm_yearextremes, buffer sizes 0 to 255 and 4 MB formats) against an independent FreeBSDstrftimereference: 0 differences for formats without the new conversions, no regression, no overrun, the caller'stmunchanged, about 52.5k cases fixed; and all 111,111 formats of length 0 to 5 over%EOkls+vZaagainst a reference written from FreeBSD's_fmt()(read at releng/9.3, 11.0, 13.2 and 14.0): 0 mismatches.tools/check_conventions.py --base origin/mainpasses;tools/pr_overlap.py --branchreports no overlap. Closed PR #2665 also editsstrftime(to preservetm_zonefor%z/%Z); this change leaves a standalone%z/%Zalone, so the two touch different behaviour but the same function.tznamefallback is untested).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 repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T11:34:08Z.
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
Pull request closed