feat: Custom dayjs.parse() - #8328
Merged
Merged
Conversation
This was referenced Jul 26, 2026
distantnative
force-pushed
the
v6/fix/dayjs-3-strict-iso
branch
from
July 26, 2026 13:28
ffdaa09 to
925e2c7
Compare
distantnative
force-pushed
the
v6/fix/dayjs-5-pattern-parse
branch
10 times, most recently
from
July 26, 2026 17:03
136f218 to
edf06c5
Compare
dayjs.pattern().read()dayjs.parse()
distantnative
force-pushed
the
v6/fix/dayjs-5-pattern-parse
branch
3 times, most recently
from
July 26, 2026 19:19
099e8ee to
8000ca5
Compare
distantnative
force-pushed
the
v6/fix/dayjs-3-strict-iso
branch
from
July 27, 2026 14:07
be9b50f to
dfdf683
Compare
distantnative
force-pushed
the
v6/fix/dayjs-5-pattern-parse
branch
from
July 27, 2026 14:10
8000ca5 to
5de2df2
Compare
distantnative
marked this pull request as ready for review
July 29, 2026 08:27
distantnative
force-pushed
the
v6/fix/dayjs-5-pattern-parse
branch
from
July 29, 2026 08:29
5de2df2 to
418701c
Compare
distantnative
force-pushed
the
v6/fix/dayjs-5-pattern-parse
branch
from
August 2, 2026 19:17
418701c to
f9a445e
Compare
Member
|
I only quickly started to test the lab and wanted to change the format. But when I try, I immediately run into an error: TypeError: can't access property "matchAll", this.source is undefined Am I not supposed to change the format or is this an issue? |
Member
Author
|
@bastianallgeier sorry seems at the end when cleaning up I renamed one string in the lab example wrongly. |
bastianallgeier
self-requested a review
August 3, 2026 15:46
bastianallgeier
approved these changes
Aug 3, 2026
bastianallgeier
left a comment
Member
There was a problem hiding this comment.
I've tested the pattern and parse tabs in the lab and it works really great.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I think this one is hard to read the code to review. Probably better to just test it out via the lab example. Trying to explain the changed approach:
dayjs.interpret()used to guess what a user typed by throwing the input at a hardcoded list of ~70 format strings and taking the first that stuck. Often rather faulty as the number of long-around bug reports shows.This PR introduces
dayjs.parse()that replaces the dayjs core plugincustomParseFormatand our previousdayjs.interpret(). It follows the following path:displayformat pattern usually. And it's not unlikely the user will type something in that follows that pattern somewhat. So the input is split into tokens and matched positionally against the display pattern's parts. Neither the separators nor the number widths have to match exactly (e.g. aDD.MM.YYYYpattern still reads2/3/24,02.03.2024and even02032024), but it has to offer something sensible for all parts of the display pattern to be used.dayjs.interpret()threw a long list at it, often faulty. But even when guessing, the display pattern should inform our guesses about which order to prioritize etc. So we test a list of guesses, but only guesses that use units the pattern also shows. And the ones agreeing with the pattern's order go first.strict: trueskips this step entirely.Because both
iso()andparse()now build datetimes explicitly, thecustomParseFormatdayjs plugin is no longer needed.DateInputstill calls the deprecatedinterpret()without a pattern. Wiring the inputs up toparse()and theirdisplaypattern is happening in: #8322Merge first
dayjs.iso()parsing #8325Changelog
✨ Enhancements
$library.dayjs.parse(input, { pattern, strict, type }): parses what a user types against a display pattern to create a date time object.dayjs#8327 also in the current Panel UI locale)☠️ Deprecated
$library.dayjs.interpret()is deprecated. Use$library.dayjs.parse()instead.For review team