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

minTime is not work #377

Open
GreatBoy opened this issue Jan 21, 2016 · 4 comments
Open

minTime is not work #377

GreatBoy opened this issue Jan 21, 2016 · 4 comments

Comments

@GreatBoy
Copy link

when i set options minTime "20:00", but is not work

@snagytx
Copy link

snagytx commented Jan 23, 2016

I think the issue is with the new DateFormatter - I see the same issue.

The issue seems to be around

_xdsoft_datetime.strtotime(options.maxTime).getTime() < max.getTime()

the new parseDate called from strtotime is responding with:

Sun Dec 31 1899 19:00:00 GMT-0600 (Central Standard Time)

while it's being compared to:

Fri Jan 22 2016 12:00:17 GMT-0600 (Central Standard Time)

but this will never happen.

Changing:

                    line_time = function line_time(h, m) {
                        var now = _xdsoft_datetime.now(), optionDateTime, current_time,
                            isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
                        now.setHours(h);

to:

                    line_time = function line_time(h, m) {
                        var now = _xdsoft_datetime.now(), optionDateTime, current_time,
                            isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
                        now.setYear(0);
                        now.setMonth(0);
                        now.setDate(0);
                        now.setHours(h);

resolves my issue but I'm sure there are other cases that I didn't consider, like seconds, milliseconds ..

@wedancedalot
Copy link

snagytx, thank you sir!

@jmwiles3
Copy link

I resolved this issue with changing this section of code

if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
    classes.push('xdsoft_disabled');
}

to this

var nowMonth = now.getMonth()+1;
if(nowMonth<10){ nowMonth = "0"+nowMonth;}
var minT = nowMonth+"/"+now.getDate()+"/"+now.getFullYear()+" "+options.minTime;
var maxT = nowMonth+"/"+now.getDate()+"/"+now.getFullYear()+" "+options.maxTime; 

if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(new Date(maxT)).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(new Date(minT)).getTime() > now.getTime())) {
    classes.push('xdsoft_disabled');
}

Similar to the solution provided by @snagytx, but done in a different location and forcing the date and adding the minTime/maxTime values to the string.

The one thing that there might be issues with is when you have different min/max times on different days. However, in my case, if all of your enabled dates have the same time range then it should be fine.

Also, you may notice I converted the string into a new date inside the if statement, mainly so I can just output the string to the console for testing before getting into the if. You could move the new Date() to the assignment section, and clean the if statement up a little.

@ashiquemohammed
Copy link

I tried doing this but dint seam to work for me , Please help .

THanks

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

5 participants