feat(libSceNKWebKit): parse legacy dates as WTF DateMath does #13565
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13565"
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 KernelPanicNT on 2026-10-30T18:28:48Z.
What
Implements the legacy
libSceNKWebKitWTF date parser from public WebKit source:WTF::parseDateFromNullTerminatedCharacters(char const*, bool&)What changes in the tree:
core/libs/prx/libSceNKWebKit/DateParsing.cpp.Export.cpp. Its declaration inInventoryExports.hppnow carries the real signature:double (const char*, bool*), because abool&is passed as a pointer. Its row comes out of the debt table.CMakeLists.txtthat buildsExport.cppandDateParsing.cppand theguest_nkwebkit_datestest.Behaviour follows WebKit's
DateMath.cppstatement by statement:MM/DD/YYYY,YYYY/MM/DD, and day-month-year with-or space separators.am/pmare applied,GMT/UTCare recognised, and+hhmm,+hhandGMT+hh:mmoffsets are read, along with the ten RFC 2822 zone names. With no zone the result is local time.strtol, because WebKit calls the platform C library.std::invalid_argument, as libc models a fault forfeholdexcept. That covers a null string and a nullbool&.std::overflow_error, as the LibreSSL ASN1 functions already throw where LibreSSL is undefined. This happens in three places:YYYY/MM/DDday count when the day is nearLONG_MAXGMT+hh:mmminute total when the minutes are nearINT_MAXINT_MAX### Functionalindocs/dev/debt/libSceNKWebKit.md, together with the overflow and null-pointer throws:parseDateFromNullTerminatedCharacters(char const*). It subtractscalculateLocalTimeOffset, which depends on two things WebKit's source does not fix:HAVE_LOCALTIME_R,HAVE_TIMEGMandHAVE_TM_GMTOFFare decided by configure checks against the port's sysroot.Relation to other open PRs:
WTF::parseES5DateFromNullTerminatedCharacters(char const*, bool&)is left to #13500, which implements it. This PR keeps its stub, declaration and debt row exactly as onmain, and implements no export that #13500 implements.core/libs/prx/libSceNKWebKit/CMakeLists.txt. Whichever merges later rebases and keeps both sets of sources and tests in that file.docs/dev/debt/libSceNKWebKit.md. Whichever merges later rebases and keeps every entry under its###section.Source of the behaviour
Pinned WebKit commit:
c55364d53f97. The export inventory matches this era:WTF::DumbPtrTraits(DumbPtrTraits.h),WTF::Optional(Optional.h) andWTF::JSONImpl(JSONValues.h).doublereturns: DateMath.h L92-L94.Inspector::NetworkBackendDispatcher::interceptRequestWithResponse, added in 514c944fc201, and still hasWTF::DumbPtrTraits, renamed in 5c5f0584738c.DateMath.cpphas no change between 49e9ee2745cd, before that window, and ca19599f2160, after it, which moved the parsers to millisecond arithmetic. So the parser in the inventory is the one at the pin.Behaviour:
Port configuration:
strtol.HAVE_LOCALTIME_R,HAVE_TIMEGMandHAVE_TM_GMTOFFby probing the sysroot. PlatformHave.h sets them only for Darwin. That is why the one-argument overload stays open.AnyPS5 lines replaced (at
6a3afa4deb18, unchanged on the currentmain):Export.cppstubInventoryExports.hppdeclarationGuest libc reused:
Tested
On Linux x86_64 (Release, GCC,
BUILD_TESTING=ON), the newguest_nkwebkit_datestest passes. It checks the result bits and theisLocalTimeflag for:MM/DD/YYYY,YYYY/MM/DDand JavaScript-style stringsam/pm, zone names and numeric offsetsNegative control:
Export.cppandInventoryExports.hppwere restored frommainandDateParsing.cppwas emptied, leaving only the old stub. The test then fails.The parser was also compared locally against WebKit's own
DateMath.cppparsing code from the pinned commit, built with a minimal WTF shim, on 12 million random date-like strings. Results andisLocalTimematched bit for bit, with about 76,000 of the strings parsing to a valid date.python3 tools/check_conventions.py --base origin/mainpasses.tools/progress.pyreports +1 implemented function.tools/pr_overlap.pyfinds no shared exports with open pull requests; the shared files are listed under What.The "8703 declarations" count in the existing
Additional callable exportsentry is left as is, to avoid conflicts with sibling branches that remove other rows of the same table.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)