bendavis78 / paper-date-picker

Material design date picker component for polymer
http://bendavis78.github.io/paper-date-picker/
MIT License
226 stars 132 forks source link

When changing date from 31st of any month, it jumps to same day in next month in calendar #182

Closed ThilinaTCH closed 6 years ago

ThilinaTCH commented 7 years ago

Hi,

I could be able to reproduce this even in Demo in here https://www.webcomponents.org/element/bendavis78/paper-date-picker/demo/demo/index.html. First set a date to 31st in any month. Ex: 31st of May 2017 Then change it to any other date in very next month Ex: Try to set 5th of June 2017

It will automatically set to 5th of July 2017 instead.

psquared2 commented 7 years ago

My workaround to this was to repeat a statement under paper-calendar.html, _tapDay function:

var item = event.model.item; //for example, we select June 5th
var newDate = new Date(this.date.getTime()); //the current date is May 31st
newDate.setYear(item.year);
newDate.setMonth(item.month); //after this statement, newDate suddenly becomes July
newDate.setMonth(item.month); //after this statement, newDate returns to June
newDate.setDate(item.day);
this.date = newDate;

Update: I suppose this is already addressed in https://github.com/bendavis78/paper-date-picker/pull/172

admwx7 commented 6 years ago

This was addressed in another PR already.