Skip to content
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

add localizedFormats to customParseFormat #1110

Merged
merged 4 commits into from
Oct 26, 2020
Merged

add localizedFormats to customParseFormat #1110

merged 4 commits into from
Oct 26, 2020

Conversation

xvaara
Copy link
Contributor

@xvaara xvaara commented Oct 4, 2020

It's not working on all the localizedFormats ( LLL, LLLL and llll ) but that would be something in the main parser since I think parsing a and A fails in non "en" locales.

@codecov
Copy link

codecov bot commented Oct 4, 2020

Codecov Report

Merging #1110 into dev will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##               dev     #1110   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          174       174           
  Lines         1621      1623    +2     
  Branches       357       357           
=========================================
+ Hits          1621      1623    +2     
Impacted Files Coverage Δ
src/plugin/customParseFormat/index.js 100.00% <100.00%> (ø)
src/plugin/localizedFormat/index.js 100.00% <100.00%> (ø)
src/plugin/localizedFormat/utils.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcdbc58...de9f43f. Read the comment docs.

@xvaara
Copy link
Contributor Author

xvaara commented Oct 8, 2020

@iamkun should I create an issue about the bug in A and a formats in localizations?

@xvaara
Copy link
Contributor Author

xvaara commented Oct 20, 2020

should the u function be in utils.js also? Like #1132 cased error? Then we'd need to move englishFormats there also?

@iamkun
Copy link
Owner

iamkun commented Oct 20, 2020

Thanks, not sure if we need this feature or not. Since new Date() already has the ability to parse such format ?

@xvaara
Copy link
Contributor Author

xvaara commented Oct 20, 2020

Thanks, not sure if we need this feature or not. Since new Date() already has the ability to parse such format ?

I don't follow. but my knowledge of localized parsing using pure javascript Date functionality is non existent. I'm just converting my app from moment to dayjs. I'm using this to validate (and create dayjs instance) user input in localised format "l LT", but if this isn't in the scope of the project I can continue using my functionality to extract the localised formats to the inputed format string... But in those I'm importing stuff from dayjs internals, so this would make it easier and future proof.

@iamkun
Copy link
Owner

iamkun commented Oct 20, 2020

Agreed. Let's see if someone needs this feature as well.

@xvaara
Copy link
Contributor Author

xvaara commented Oct 25, 2020

What I'm reading from docs, new Date() doesn't parse any locales... or am I missing something? I noticed that this didn't work when converting from moment, and hacked something to get by. But since it's a hack that depends on importing locales to my code and inlining en locales (since they aren't exported anywhere) I looked at how to implement it directly in dayjs. Since dayjs is supposed to be same api as moment, shouldn't this also be implemented? For this pull request I looked how moment does this, and It's pretty much the same.

@iamkun
Copy link
Owner

iamkun commented Oct 26, 2020

What do you mean by new Date() doesn't parse any locales? Day.js supports parsing in a specific locale like dayjs('2018 Enero 15', 'YYYY MMMM DD', 'es')

@xvaara
Copy link
Contributor Author

xvaara commented Oct 26, 2020

What do you mean by new Date() doesn't parse any locales?

Well you said that new Date() parses such formats 6 days ago... but I can't seem to find anything about parsing different formats, only hints to use moment.js. Since localizedFormats is moment.js invention, I really think no other parses them (except luxon).

Day.js supports parsing in a specific locale like dayjs('2018 Enero 15', 'YYYY MMMM DD', 'es')

Yes, but doesn't parse the localizedFormats, that's the point of this pull request.

@iamkun
Copy link
Owner

iamkun commented Oct 26, 2020

Oh, I see, what I mean above, 'LLLL' string like Thursday, September 4, 1986 8:30 PM is a valid input to new Date(), that is to say, even if we don't implement this, dayjs('Thursday, September 4, 1986 8:30 PM') still outputs an expected result.

@xvaara
Copy link
Contributor Author

xvaara commented Oct 26, 2020

that leaves every other variation of formats and locales not functioning...

@iamkun
Copy link
Owner

iamkun commented Oct 26, 2020

Will this is just an example, other formats in localizedFormats should all have be supported.

@xvaara
Copy link
Contributor Author

xvaara commented Oct 26, 2020

they are not. As the test case I included. It fails without this patch.

Here the same test with one locale on codesandbox: https://codesandbox.io/s/lingering-dream-tm4tk?file=/src/index.js

@iamkun
Copy link
Owner

iamkun commented Oct 26, 2020

Well, my bad. then this pr makes sense.

@iamkun iamkun merged commit 8a08112 into iamkun:dev Oct 26, 2020
iamkun pushed a commit that referenced this pull request Nov 5, 2020
## [1.9.5](v1.9.4...v1.9.5) (2020-11-05)

### Bug Fixes

* customParseFormat plugin supports parsing localizedFormats  ([#1110](#1110)) ([402b603](402b603))
* fix customParseFormat plugin parse meridiem bug ([#1169](#1169)) ([9e8f8d9](9e8f8d9)), closes [#1168](#1168)
* fix devHelper error in umd bundle in browser ([#1165](#1165)) ([d11b5ee](d11b5ee))
* fix utc plugin diff bug in DST ([#1171](#1171)) ([f8da3fe](f8da3fe)), closes [#1097](#1097) [#1021](#1021)
* isoWeek plugin type ([#1177](#1177)) ([c3d0436](c3d0436))
* update localeData plugin to support meridiem ([#1174](#1174)) ([fdb09e4](fdb09e4)), closes [#1172](#1172)
* update timezone plugin parse Date instance / timestamp logic & remove useless test ([#1183](#1183)) ([a7f858b](a7f858b))
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this pull request May 10, 2022
## [1.9.5](iamkun/dayjs@v1.9.4...v1.9.5) (2020-11-05)

### Bug Fixes

* customParseFormat plugin supports parsing localizedFormats  ([#1110](iamkun/dayjs#1110)) ([402b603](iamkun/dayjs@402b603))
* fix customParseFormat plugin parse meridiem bug ([#1169](iamkun/dayjs#1169)) ([9e8f8d9](iamkun/dayjs@9e8f8d9)), closes [#1168](iamkun/dayjs#1168)
* fix devHelper error in umd bundle in browser ([#1165](iamkun/dayjs#1165)) ([d11b5ee](iamkun/dayjs@d11b5ee))
* fix utc plugin diff bug in DST ([#1171](iamkun/dayjs#1171)) ([f8da3fe](iamkun/dayjs@f8da3fe)), closes [#1097](iamkun/dayjs#1097) [#1021](iamkun/dayjs#1021)
* isoWeek plugin type ([#1177](iamkun/dayjs#1177)) ([c3d0436](iamkun/dayjs@c3d0436))
* update localeData plugin to support meridiem ([#1174](iamkun/dayjs#1174)) ([fdb09e4](iamkun/dayjs@fdb09e4)), closes [#1172](iamkun/dayjs#1172)
* update timezone plugin parse Date instance / timestamp logic & remove useless test ([#1183](iamkun/dayjs#1183)) ([a7f858b](iamkun/dayjs@a7f858b))
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this pull request May 10, 2022
## [1.9.5](iamkun/dayjs@v1.9.4...v1.9.5) (2020-11-05)

### Bug Fixes

* customParseFormat plugin supports parsing localizedFormats  ([#1110](iamkun/dayjs#1110)) ([402b603](iamkun/dayjs@402b603))
* fix customParseFormat plugin parse meridiem bug ([#1169](iamkun/dayjs#1169)) ([9e8f8d9](iamkun/dayjs@9e8f8d9)), closes [#1168](iamkun/dayjs#1168)
* fix devHelper error in umd bundle in browser ([#1165](iamkun/dayjs#1165)) ([d11b5ee](iamkun/dayjs@d11b5ee))
* fix utc plugin diff bug in DST ([#1171](iamkun/dayjs#1171)) ([f8da3fe](iamkun/dayjs@f8da3fe)), closes [#1097](iamkun/dayjs#1097) [#1021](iamkun/dayjs#1021)
* isoWeek plugin type ([#1177](iamkun/dayjs#1177)) ([c3d0436](iamkun/dayjs@c3d0436))
* update localeData plugin to support meridiem ([#1174](iamkun/dayjs#1174)) ([fdb09e4](iamkun/dayjs@fdb09e4)), closes [#1172](iamkun/dayjs#1172)
* update timezone plugin parse Date instance / timestamp logic & remove useless test ([#1183](iamkun/dayjs#1183)) ([a7f858b](iamkun/dayjs@a7f858b))
splashwizard pushed a commit to splashwizard/tracking-time that referenced this pull request Oct 21, 2024
## [1.9.5](iamkun/dayjs@v1.9.4...v1.9.5) (2020-11-05)

### Bug Fixes

* customParseFormat plugin supports parsing localizedFormats  ([#1110](iamkun/dayjs#1110)) ([402b603](iamkun/dayjs@402b603))
* fix customParseFormat plugin parse meridiem bug ([#1169](iamkun/dayjs#1169)) ([9e8f8d9](iamkun/dayjs@9e8f8d9)), closes [#1168](iamkun/dayjs#1168)
* fix devHelper error in umd bundle in browser ([#1165](iamkun/dayjs#1165)) ([d11b5ee](iamkun/dayjs@d11b5ee))
* fix utc plugin diff bug in DST ([#1171](iamkun/dayjs#1171)) ([f8da3fe](iamkun/dayjs@f8da3fe)), closes [#1097](iamkun/dayjs#1097) [#1021](iamkun/dayjs#1021)
* isoWeek plugin type ([#1177](iamkun/dayjs#1177)) ([c3d0436](iamkun/dayjs@c3d0436))
* update localeData plugin to support meridiem ([#1174](iamkun/dayjs#1174)) ([fdb09e4](iamkun/dayjs@fdb09e4)), closes [#1172](iamkun/dayjs#1172)
* update timezone plugin parse Date instance / timestamp logic & remove useless test ([#1183](iamkun/dayjs#1183)) ([a7f858b](iamkun/dayjs@a7f858b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants