Luxon: Info.weekdays seems to be mutable

Created on 5 Nov 2020  路  5Comments  路  Source: moment/luxon

Describe the bug
It seems that Info.weekdays is mutable and it affects DateTime instances.

To Reproduce
To reproduce, I just called .pop() on Info.weekdays in the console on your website:

https://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html

Here's a screenshot of the console:

Screen Shot 2020-11-05 at 10 59 59 AM

Actual vs Expected behavior
Luxon claims to be immutable. My expectation is that running Info.weekdays('short') would give me a new copy of the array instead of a global constant that is used by DateTime instances.

Desktop (please complete the following information):

  • macOS
  • Chrome 86
  • luxon v1.25.0

Additional context
The reason I am doing this is because I'm trying to get a copy of Info.weekdays('short') but with Sunday being at the beginning of the array.

bug

All 5 comments

Yeha, Luxon should copy the array before returning it. Would accept a PR

Thanks, @icambron. I'll put together a PR.

Sorry y'all, haven't had time to work on that pull request.

I had some time so opened a PR to fix this, any review would be appreciated.

Closed by #829

Was this page helpful?
0 / 5 - 0 ratings