gianlucaparadise/telegraf-calendar-telegram

setMinDate and setMaxDate pass by reference

machinas-achim opened this issue · 1 comments

Another potential improvement:

        calendarWidget.setMinDate(myMinDate));
        calendarWidget.setMaxDate(myMaxDate);

as per documentation can actually lead to myMinDate and myMaxDate to have their value changed as a side effect when generating a new view. So either make the documentation clearer to pass a completely new (throw-away) object to avoid this:

        calendarWidget.setMinDate(new Date(myMinDate));
        calendarWidget.setMaxDate(new Date(myMaxDate));

or adjust the setter/getter functions like this:

	setMinDate(date) {
		this.helper.setMinDate(new Date(date));
		return this;
	}

instead of simply passing the reference to the object as is the case at the moment:

		this.helper.setMinDate(date);

Hi!
Thank you for the suggestion! You can find this fix in version 1.5.6.
I preferred to create a new Date object.