Skip to content

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

@johnmurphy01

Description

@johnmurphy01

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions