-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fields] Support format without separator #12489
[fields] Support format without separator #12489
Conversation
@@ -214,6 +214,10 @@ export class AdapterLuxon implements MuiPickersAdapter<DateTime, string> { | |||
// Extract escaped section to avoid extending them | |||
const catchEscapedSectionsRegexp = /''|'(''|[^'])+('|$)|[^']*/g; | |||
|
|||
// This RegExp tests if a string is only mad of supported tokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method was escaping tokens when they were not separated by any character.
.join('|')})`, | ||
'g', // used to get access to lastIndex state | ||
); | ||
// This RegExp tests if the beginning of a string corresponds to a supported token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworked this method because it was duplicating the 1st character of the 2nd token (once inside the token and once as a separator).
Since we catch the whole token in one passage in the loop, we can replace the for
with a while
and stop populating currentTokenValue
incrementaly. This makes the whole behavior simplet IMHO.
Now we also support glued tokens (e.g: HHMM
) which forces us to check if a word is composed only of tokens and if so to split them and create the sections.
The only thing we can't support is stuff like YYYYdeMM
but I think it's a very very weird format 😬
Deploy preview: https://deploy-preview-12489--material-ui-x.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fix #12487