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

Bug while iterating weeks between 2 dates #110

Open
DheerajKN opened this issue Feb 19, 2019 · 1 comment
Open

Bug while iterating weeks between 2 dates #110

DheerajKN opened this issue Feb 19, 2019 · 1 comment

Comments

@DheerajKN
Copy link

There is a while Bug I am iterating with weeks between 2 dates and here is the code that I used

var itr = moment.twix(new Date('2018-10-06T00:00:00'),new Date('2018-11-12T00:00:00')).iterate("weeks");
var range=[];
while(itr.hasNext()){
    range.push(itr.next().format("YYYY-M-D"))
}
console.log(range);

Which generates the below result:

"2018-9-30"
"2018-10-7"
"2018-10-14"
"2018-10-21"
"2018-10-28"
"2018-11-4"
"2018-11-11"

When I was requesting for week sequence starting from '6th October' why I am getting results from a week prior.

Expected Result:

"2018-10-6"
"2018-10-12"
"2018-10-19"
"2018-10-26"
"2018-11-1"
"2018-11-8"

How can I resolve this issue??

@America-first-melon
Copy link

moment(start).twix(end).toArray("week")

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

2 participants