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

dddd always returns dow after using updateLocale #3121

Closed
mdibaiee opened this issue Apr 18, 2016 · 5 comments
Closed

dddd always returns dow after using updateLocale #3121

mdibaiee opened this issue Apr 18, 2016 · 5 comments
Labels

Comments

@mdibaiee
Copy link

Hey,

There's something pretty weird with updateLocale and setting week: { dow: 6 }.

moment.updateLocale('en', { week: { dow: 6 } });
moment.locale('en');
moment('Sunday', 'dddd').weekday(); // 6
moment('Friday', 'dddd').weekday(); // 6
moment('Monday', 'dddd').weekday(); // 6
@mdibaiee
Copy link
Author

I found a workaround, this just works fine:

moment().day('Saturday').weekday(); // 0
moment().day('Sunday').weekday(); // 1

@maggiepint maggiepint added the Bug label Apr 19, 2016
@maggiepint
Copy link
Member

Yep, that's not right.
See below:

moment.updateLocale('en', { week: { dow: 6 } });
moment.locale('en');
moment('Tuesday', 'dddd').format()
"2016-01-01T00:00:00-06:00" //this is a friday

Things start to work if I specify the week.doy property as well. Before updateLocale this was a known issue. I thought that after updateLocale it should have been fixed. Will investigate.

@ichernev
Copy link
Contributor

@mdibaiee this is related to the fact that updateLocale('en', ...) doesn't work like updateLocale for all other locales. This is also reported in #3137, and fixed in #3235.

For now just specify both dow and doy and it should work.

@ichernev
Copy link
Contributor

Closing this in favor of #3137 and #3235, I just ran this example with the PR and it produces (correctly):

>  moment.updateLocale('en', { week: { dow: 6 } })
...
> moment.locale('en');
'en'
> moment('Sunday', 'dddd').weekday();
1
> moment('Friday', 'dddd').weekday();
6
> moment('Monday', 'dddd').weekday();
2

@mdibaiee
Copy link
Author

@ichernev alright, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants