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

NgbCalendar.getNext() unexpected behaviour #3146

Closed
ahdbk opened this issue Apr 26, 2019 · 2 comments
Closed

NgbCalendar.getNext() unexpected behaviour #3146

ahdbk opened this issue Apr 26, 2019 · 2 comments

Comments

@ahdbk
Copy link

ahdbk commented Apr 26, 2019

Bug description:

getNext() is supposed to add a periode to a date.

for example if the date is 2019-04-26 when we add a year we expect to have 2020-04-26.

With the actual implementation we will have 2019-01-01

this is the actual method implementation:

getNext(date: NgbDate, period: NgbPeriod = 'd', number = 1) {
    let jsDate = toJSDate(date);

    switch (period) {
      case 'y':
        return new NgbDate(date.year + number, 1, 1);
      case 'm':
        jsDate = new Date(date.year, date.month + number - 1, 1, 12);
        break;
      case 'd':
        jsDate.setDate(jsDate.getDate() + number);
        break;
      default:
        return date;
    }
    return fromJSDate(jsDate);
  }
@maxokorokov
Copy link
Member

Thanks for reporting it, there is a PR opened for this since a long time → #1277
This should also fix keyboard navigation.

@maxokorokov
Copy link
Member

Fixed by #3355, will be part of 5.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants