function Validaattori_1viikko(source,args)
{
var star_tdate;
var end_date;
start_date = document.all("Laina_alku").value;
end_date = document.all("Laina_loppu").value;
var start_day;
var end_day;
var start_month;
var end_month;
var start_year;
var end_year;
start_day = start_date.substring(0,2);
end_day = end_date.substring(0,2);
start_month = start_date.substring(3,5);
end_month = end_date.substring(3,5);
start_year = start_date.substring(6,10);
start_year = end_date.substring(6,10);
var startingdate = new Date();
startingdate.setMonth(parseInt(start_month)-1,parseInt(start_day));
startingdate.setYear(parseInt(start_year));
var endingdate = new Date();
date_loppu.setMonth(parseInt(end_month)-1,parseInt(end_day));
date_loppu.setYear(parseInt(end_year));
var dif_indays = Math.round( (endingdate.getTime() -
startingdate.getTime()) / (1000 * 60 * 60 * 24) );
// For debug
document.writeln(start_date + " " + end_date);
document.writeln(startingdate + " " + endingdate);
if ( (erotus_paivia < 7) && (erotus_paivia > 0) )
args.IsValid = true;
else
args.IsValid = false;
}
So Im using this code with ASP.net pages as clientvalidation function.
I don't think that has anything to do with the actual problem though.
So if i pick start_date of lets say "29.04.2004" and end_date
"06.05.2004" I will get this as debug info:
29.04.2004 06.05.2004 Thu Apr 29 12:54:05 UTC+0300 2004 Thu May 6
12:54:05 UTC+0300 2004
Everything seems to be working just fine, but...
If i pick end_date of "08.04.2004" (or "09.05.2004") i get this:
29.04.2004 08.05.2004 Thu Apr 29 12:55:42 UTC+0300 2004 Fri Apr 30
12:55:42 UTC+0300 2004
End date is completely wrong.
Then again if i pick "10.05.2004" i get:
..04.2004 10.05.2004 Thu Apr 29 12:56:36 UTC+0300 2004 Mon May 10
12:56:36 UTC+0300 2004
So those 2 dates 8 and 9.5 are giving all wrong dates and Im all out
of answers. Haven't found that error with any other dates yet.