I have been developing a new website and have come across a strange datetime problem which I cannot seem to work out what is wrong.
My staging server is here: Link
As you can see, people can enquire about taxis "Now" or in the "Future".
What should happen is that if you chose "Future" and put in a date/time more than 2 hours ahead then I will be able to give you live quotes for taxis. If the lead time is less than 2 hours ahead then you should not see any "live" quotes.
I am developing it based on an API from a company in Finland and they have been testing it as well.
The guys in Finland are reporting that even when they select "Now" they are still getting live quotes when they shouldn't.
I use some JavaScript to populate the datetime selectors on the page like this:
var d = new Date();
var curr_hour = d.getHours(); // this is in 24 hour
var curr_minute = d.getMinutes();
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1; //Months are zero based
var curr_year = d.getFullYear();
if (curr_minute < 15) { $("#enquiry_timeMins").val(15); }
if (curr_minute >= 15 && curr_minute < 30) { $("#enquiry_timeMins").val(30); }
if (curr_minute >= 30 && curr_minute < 45) { $("#enquiry_timeMins").val(45); }
if (curr_minute >= 45 && curr_minute < 59) { $("#enquiry_timeMins").val(00); curr_hour = curr_hour + 1; }
if (curr_hour >= 12) {
$("#enquiry_timeAMPM").val("PM");
$("#enquiry_timeHours").val(curr_hour - 12);
}
else {
$("#enquiry_timeAMPM").val("AM");
$("#enquiry_timeHours").val(curr_hour);
}
$("#enquiry_pickupTime").val(curr_date + "/" + curr_month + "/" + curr_year);
and then in my controller I do this:
theRoute.enquiry.pickupTime = theRoute.enquiry.pickupTime.AddHours(theRoute.enquiry.timeHours);
theRoute.enquiry.pickupTime = theRoute.enquiry.pickupTime.AddMinutes(theRoute.enquiry.timeMins);
if (theRoute.enquiry.timeAMPM == "PM") { theRoute.enquiry.pickupTime = theRoute.enquiry.pickupTime.AddHours(12); }
This seems to work perfectly for me but I'm based in the UK. The guys in Finland happen to be 2 hours ahead as well. Which seems more than a coincidence as the lead time is also 2 hours ahead.
Can anyone see anything that I haven't considered that makes this work in the UK but not in Finland, and possibly other countries as well?