Skip to content

Question about start date later than end date #268

@zh3ngyuan

Description

@zh3ngyuan

version: v4.0.2
when I run the following script:

var start = moment('10/11/2019', 'MM/DD/YYYY');
var end = moment('10/05/2019', 'MM/DD/YYYY');
Array.from(moment.range(start, end).by('day')).map(function(date) {
    return date.format()
});

I got the output like this

// [
//     "2019-10-11T00:00:00-07:00", 
//     "2019-10-12T00:00:00-07:00",
//     "2019-10-13T00:00:00-07:00", 
//     "2019-10-14T00:00:00-07:00", 
//     "2019-10-15T00:00:00-07:00", 
//     "2019-10-16T00:00:00-07:00", 
//     "2019-10-17T00:00:00-07:00"
// ]

Apparently, the result is incorret, and what I expected should be [] or [endDate, ... , startDate]

I was wondering if there is any validation for the case that start date is later than the end date? otherwise, I need to validate it by myself before generate the range.

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