Skip to content

Commit

Permalink
fix(datepicker): use noon instead of midnight for date conversion
Browse files Browse the repository at this point in the history
Fixes #1615

Closes #1676
  • Loading branch information
maxokorokov authored and pkozlowski-opensource committed Jul 11, 2017
1 parent 62c5ae3 commit 2fdd8f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/datepicker/ngb-calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function fromJSDate(jsDate: Date) {
return new NgbDate(jsDate.getFullYear(), jsDate.getMonth() + 1, jsDate.getDate());
}
function toJSDate(date: NgbDate) {
const jsDate = new Date(date.year, date.month - 1, date.day);
const jsDate = new Date(date.year, date.month - 1, date.day, 12);
// this is done avoid 30 -> 1930 conversion
if (!isNaN(jsDate.getTime())) {
jsDate.setFullYear(date.year);
Expand Down Expand Up @@ -48,7 +48,7 @@ export class NgbCalendarGregorian extends NgbCalendar {
case 'y':
return new NgbDate(date.year + number, 1, 1);
case 'm':
jsDate = new Date(date.year, date.month + number - 1, 1);
jsDate = new Date(date.year, date.month + number - 1, 1, 12);
break;
case 'd':
jsDate.setDate(jsDate.getDate() + number);
Expand Down

0 comments on commit 2fdd8f1

Please sign in to comment.