Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

pickadate-active not working #42

Open
davisford opened this issue Feb 3, 2015 · 1 comment
Open

pickadate-active not working #42

davisford opened this issue Feb 3, 2015 · 1 comment

Comments

@davisford
Copy link

Hi, I noticed the .pickadate-active class is not getting set.

I found a few potential issues:

scope.classesFor = function(date) {
    var extraClasses = indexOf.call(selectedDates, date.date) >= 0 ? 'pickadate-active' : null;
    return date.classNames.concat(extraClasses);
};

That is sending the date.date property into indexOf, but date.date is a string representation of the date. It should send date.dateObj to compare the full date object.

However, even if you fix that it still doesn't work, because there is an offset on the time. If you run this code:

scope.classesFor = function(date) {
    for (var i = 0; i < selectedDates.length; i++) {
        var d1 = selectedDates[i], d2 = date.dateObj;
        console.log('compare %s with %s', d1, d2);
        console.log('compare %d with %d', d1.getTime(), d2.getTime());
    }
    var extraClasses = indexOf.call(selectedDates, date.dateObj) >= 0 ? 'pickadate-active' : null;
    return date.classNames.concat(extraClasses);
};

And you reach the same day that is selected, you end up with this; note the time offset which will always cause the comparison to fail:

 compare Tue Feb 03 2015 00:00:00 GMT-0500 (EST) with Tue Feb 03 2015 03:00:00 GMT-0500 (EST)
(index):28 

compare 1422939600000 with 1422950400000
@gschammah
Copy link
Contributor

Hi @davisford

I couldn't reproduce this. Could you please create a plunker reproducing this bug? Use the latest version of the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants