-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
fix: correctly handle locale in parse #401
Conversation
}: { formats?: Partial<DateIOFormats>; locale?: string } = {}) { | ||
this.locale = locale || "en"; | ||
this.locale = locale || "en-US"; |
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.
Because the default for luxon is en-US
not en, adding the handling to pass through the locale to parse was breaking one of the non locale aware parse tests because it was changing it from en-US
to en
. Using en-US
should ensure that the default behavior doesn't change at all
Codecov Report
@@ Coverage Diff @@
## master #401 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 12
Lines 553 555 +2
Branches 64 65 +1
=========================================
+ Hits 553 555 +2
Continue to review full report at Codecov.
|
@@ -69,7 +69,7 @@ export default class LuxonUtils implements IUtils<DateTime> { | |||
return null; | |||
} | |||
|
|||
return DateTime.fromFormat(value, formatString); | |||
return DateTime.fromFormat(value, formatString, { locale: this.locale }); |
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 fixes luxon
@@ -82,6 +78,10 @@ export default class MomentUtils implements IUtils<defaultMoment.Moment> { | |||
return null; | |||
} | |||
|
|||
if (this.locale) { | |||
return this.moment(value, format, this.locale, true); |
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 fixes moment
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.
Please run yarn prettier --write './packages/**/*.{js,jsx,ts,tsx,json,css,md,mdx}'.
And add a test for if
line. Coverage should be 100%
I ran this, but it generated a bunch of changes in several different files. It seems like my prettier is getting different results than yours. The only thing I could think of that would cause that is differences in |
Thanks! |
This makes sure that locale gets passed through to parse in Luxon and moment