Skip to content

Conversation

@cbranch101
Copy link
Contributor

This makes sure that locale gets passed through to parse in Luxon and moment

formats,
}: { formats?: Partial<DateIOFormats>; locale?: string } = {}) {
this.locale = locale || "en";
this.locale = locale || "en-US";
Copy link
Contributor Author

@cbranch101 cbranch101 Jun 26, 2020

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-commenter
Copy link

codecov-commenter commented Jun 26, 2020

Codecov Report

Merging #401 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #401   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          553       555    +2     
  Branches        64        65    +1     
=========================================
+ Hits           553       555    +2     
Impacted Files Coverage Δ
packages/dayjs/src/dayjs-utils.ts 100.00% <100.00%> (ø)
packages/hijri/src/hijri-utils.ts 100.00% <100.00%> (ø)
packages/jalaali/src/jalaali-utils.ts 100.00% <100.00%> (ø)
packages/luxon/src/luxon-utils.ts 100.00% <100.00%> (ø)
packages/moment/src/moment-utils.ts 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 e8ce35c...077a43d. Read the comment docs.

}

return DateTime.fromFormat(value, formatString);
return DateTime.fromFormat(value, formatString, { locale: this.locale });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes luxon

}

if (this.locale) {
return this.moment(value, format, this.locale, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes moment

Copy link
Owner

@dmtrKovalenko dmtrKovalenko left a 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%

@cbranch101
Copy link
Contributor Author

cbranch101 commented Jun 29, 2020

Please run yarn prettier --write './packages/**/*.{js,jsx,ts,tsx,json,css,md,mdx}'.

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 prettier version. The version in my node_modules is 2.0.5

@dmtrKovalenko
Copy link
Owner

Thanks!

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.

3 participants