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

en locale is supposed to be US but startOf week is Monday #5187

Open
macpham opened this issue Aug 5, 2019 · 5 comments

Comments

@macpham
Copy link

commented Aug 5, 2019

Describe the bug
I'm under the impression the default locale en is supposed to represent English (United States) since there is no en-us. #3569 (comment) However when I try to get the start of the week with en, I get Monday and in the US and in general North America the week starts on Sunday. en-CA, English (Canada) works as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Set locale to en-us, it goes to en
  2. Do moment.startOf('week') or check moment.localeData().firstDayOfWeek()

Expected behavior

  1. First day of the week in the US should be Monday or day 0 not 1.

https://github.com/moment/moment/blob/develop/src/lib/units/week.js#L45

image

I'm using moment 2.24.0.

Is this a bug or is my understanding bugged?

As a workaround, I am doing: moment.updateLocale('en', { week: { dow: 0 } });

@ashsearle

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2019

Are you using an environment or plugin that changes moment locale / locale-data?

Things look fine in a plain jsfiddle

@macpham

This comment has been minimized.

Copy link
Author

commented Aug 8, 2019

Thanks @ashsearle for checking. I was looking for any other reference to updateLocale and I couldn't find anything. Is there another way to update locale / locale data other than that function that I am using to fix this?

This is on MacOS with Chrome Incognito, others working with me experience the same thing so it must be something in our app then.

@ashsearle

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2019

If some other code is using updateLocale you might be able to see evidence of that by checking moment.localeData().parentLocale - it'd normally be undefined for the default 'en' locale.

It's also possible something's directly manipulating the object returned by localeData() - that'll be harder to detect (but guess checking your entire app for 'localeData' should narrow down the search.)

@macpham

This comment has been minimized.

Copy link
Author

commented Aug 9, 2019

Very odd, I have no modification to parentLocale, its undefined and I searched for references to localeData in my source code and found none other than the ones to generate this print out below... Perhaps one of my dependencies is doing something to it? There is no other way to influence this value?

image

@ashsearle

This comment has been minimized.

Copy link
Contributor

commented Aug 11, 2019

i don't think there's any other way to influence this, so I'd definitely search your node_modules / dependencies and check if something jumps out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.