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

Range .by('day') causing duplicate on Daylight Savings Time #276

Open
johnmurphy01 opened this issue Apr 9, 2020 · 0 comments
Open

Range .by('day') causing duplicate on Daylight Savings Time #276

johnmurphy01 opened this issue Apr 9, 2020 · 0 comments

Comments

@johnmurphy01
Copy link

I'm trying to use this add-on in order to get an array of dates from 2020-01-01 to 2020-12-31.

const startDate = moment.utc('2020-01-01').toDate()
const endDate = moment.utc('2020-12-31').toDate()

const rangeBetweenStartAndEnd = Array.from(moment.range(startDate, endDate).by('day'))
return rangeBetweenStartAndEnd.map((day) => {
...
})

However, my resulting JSON object has duplicate days, one of which is 2020-03-08 which is Daylight Savings Time. I have a lot of resulting data but I assume if this is a time savings issue, then there would be another duplicate on November 1?

I feel like maybe I'm doing something wrong because surely this issue would have been caught earlier? Maybe it has something to do with me converting my moment dates back to JS dates?

Any help would be appreciated

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

No branches or pull requests

1 participant