Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

today private variable should not be static #165

Closed
IlanFrumer opened this issue Dec 22, 2015 · 2 comments
Closed

today private variable should not be static #165

IlanFrumer opened this issue Dec 22, 2015 · 2 comments

Comments

@IlanFrumer
Copy link
Contributor

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
Copy link

adion commented Jan 15, 2016

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
Copy link
Owner

Twipped commented Feb 25, 2016

This has been fixed in v0.6

@Twipped Twipped closed this as completed Feb 25, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants