Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

max and min date also compares by time #181

Open
AnirudhaGohokar opened this issue Feb 21, 2017 · 1 comment
Open

max and min date also compares by time #181

AnirudhaGohokar opened this issue Feb 21, 2017 · 1 comment

Comments

@AnirudhaGohokar
Copy link

Hi,

When using mdp-max-date and mpd-min-date, the comparison is being done with time as well.
So, consider this

max date--> Wed Jan 31 2018 00:00:00 GMT+0530 (India Standard Time)
current date--> Wed Jan 31 2018 12:43:47 GMT+0530 (India Standard Time)

will evaluate to false even though the dates match becuase current date > max date

A simple change of doing comparison based on date only in isDayEnabled function should fix the issue.

@AnirudhaGohokar
Copy link
Author

For now I have fixed this issue by stripping out the time in isDayEnabled function and it seems to be working good.

this.isDayEnabled = function (day) {
                var min_date = this.minDate ? moment(this.minDate).startOf('day').toDate() : false;
                var max_date = this.maxDate ? moment(this.maxDate).startOf('day').toDate() : false;
                var current_date = moment(day).startOf('day').toDate();
                var isEnabled = (!min_date || min_date <= current_date) &&
                        (!max_date || max_date >= current_date) &&
                        (!self.dateFilter || !self.dateFilter(current_date));
                return isEnabled;
            };

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

No branches or pull requests

1 participant