Twipped / Kalendae

A javascript date picker that just works.
MIT License
1.99k stars 285 forks source link

today private variable should not be static #165

Closed IlanFrumer closed 8 years ago

IlanFrumer commented 8 years ago

When the date changes (at midnight) it won't update. This is because it only gets initialized once.

Source: https://github.com/ChiperSoft/Kalendae/blob/master/src/moment.ext.js#L19

today = Kalendae.moment().startOf('day');
adion commented 8 years ago

I've patched this locally so that today is a function call (effectively what you've done in #167), which IIRC is only called 5 times by Kalendae.

function today() {
    return moment().startOf('day');
}

...

return moment(date).startOf('day').yearDay() >= today().yearDay();

etc.

The added benefit of this is if you're using moment-timezone and you're setting a default timezone this will cover any possible race-conditions where the timezone is set after the today comparison is performed.

Twipped commented 8 years ago

This has been fixed in v0.6