Join Bytes! (Dhaval) writes:
[color=blue]
> Well I am facing this strange issue with javascript. Specifically on
> the 26th October 2003, when I select any roomtype I get the rate 0 if[/color]
I can see the problem. It happens in both IE and Opera.
If you chose the 25th of October instead, and chose two nights,
only one is counted, and likewise for any other selection that covers
the 26th. It is as if it isn't counted.
The problem is probably in the code (comments removed):
---
function dateAdd(baseStr,days){
baseTime = baseStr.split("/");
time = new Date(baseTime[2],baseTime[1]-1,baseTime[0]);
time = new Date(time.valueOf()+days*1000*3600*24);
return padDigit(time.getDate())+"/"+padDigit(time.getMonth()+1)+"/" +time.getYear();
}
---
which is called as:
---
departdate = dateAdd(arrivaldate,nights);
---
The problem is that the 26th of October is the day when daylight saving
changes back. That means that that day is 25 hours long. Your code
only multiply with 24, and adding 24 hours to the beginning of the 26th
is still on the 26th.
Code using 1000*3600*24 is usually not the smartest way to do what it
does (as I have been taught by reading this group :).
The best way to add a number of days to a date is:
---
time.setDate(time.getDate() + days);
---
That works by changing the date, not the millisecond. It overflows
correctly into next month, i.e., adding ten days to the 26th of
October gives the 5th of November.
[color=blue]
>
http://autouae.bpweb.net/reservation.html[/color]
[color=blue]
> Please advise as I have not used any date specific functions at all...[/color]
You use Date in several places. *Not* handling daylight saving is a very
date specific act two times a year.
/L
--
Lasse Reichstein Nielsen -
Join Bytes!
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'