-
Notifications
You must be signed in to change notification settings - Fork 604
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
DateTimeFormatter: Dynamically augment skeleton #604
Conversation
Dynamically augment availableFormats Fixes globalizejs#271
Migrate to container-based infrastructure http://docs.travis-ci.com/user/migrating-from-legacy/
Rework of `getBestMatchPattern` algorithm - properly handle close parts of sekletons, i.e. `L` and `M` - better distance calculating Call to `getBestMatchPattern` before splitting skeleton to date and time parts Add a lot of test cases to `expandPattern` function. Fixes globalizejs#271
Thank you for your pull request. It looks like this may be your first contribution to a jQuery Foundation project, if so we need you to sign our Contributor License Agreement (CLA). 📝 Please visit http://contribute.jquery.org/CLA/ to sign. After you signed, the PR is checked again automatically after a minute. If there's still an issue, please reply here to let us know. If you've already signed our CLA, it's possible your git author information doesn't match your CLA signature (both your name and email have to match), for more information, check the status of your CLA check. |
@rxaviers My algorithm is close to http://www.unicode.org/reports/tr35/tr35-dates.html#Matching_Skeletons, but seems with several bugs in it. I do not handle rule "Numeric and text fields are given a larger distance from each other. MMM ≈ MM" I'll work on it but later (next week I suppose) |
result = result + str; | ||
} | ||
return result; | ||
} |
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.
Let's move this function into ./src/util/string/repeat-str.js
. Maybe ./src/util/string/pad.js
could reuse it.
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.
Maybe we could use String.prototype.repeat
with some of es6-shim?
Also check/benchmark these ecma-402 polyfil implementations, can we reuse the idea/algo? |
} | ||
|
||
return bestMatchFormat.join( "" ); | ||
} |
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.
In general about the functions above, can .match(datePatternRe)
and normalizePatternType
be made in advance in the caller function so that you don't need to execute these over and over?
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.
You mean some sort of caching? But this could be a memory issue...
Any movement on this? I could really use this fix. |
It is stalled. Would you like to take it over? I'd be happy if you could address the above comments. You could create a new pull request on top of this one with additional commits. Just let me know if you have any questions. Thanks |
Fixes #271
This is rework of #462.
I have implemented another skeleton pattern comparison algorithm, which fixes a lot of issues I have found in #462 implementation.
Also I have added a lot of tests, which were tested manually across Intl.DateTimeFormat and ICU Flex Test.
But not all resulst same from Flex Test and my implementation. This is difference table:
GyMMMEd
EEE, MMM d, y G
E, MMM d, y G
GyMMMEdhms
EEE, MMM d, y G, h:mm:ss a
E, MMM d, y G, h:mm:ss a
GyMMMEd
andhms
patterns, which are both available in cldr-data and merged withdateTimeFormat.medium
hhmm
h:mm a
hh:mm a
h:mm a
tohh:mm a
because user requestedhh
in his patternEHmms
EEE HH:mm:ss
E HH:mm:ss
EHms
toE HH:mm:ss
. Because in result patternmm
already present, we don't need to augment any more.And all other differences are similar. In fact, I am really can not understand, why flexTest augments
E
toEEE
, if you know why please tell me :-)