I'm having a bit of trouble with a date copying function I've tried implimenting. What it does is takes a string in the format "HH:MM" to represent the time and returns a date object with the same date but a specific time.
The code responsible for this is
Date.prototype.copy=function(time){
copy = new Date();
copy.setDate(this.getDate());
copy.setMonth(this.getMonth());
copy.setYear(this.getYear());
bits=time.split(/:/);
copy.setHours(bits[0]);
copy.setMinutes(bits[1]);
// Debugging info
document.getElementById("testDiv").innerHTML+="Turning "+bits[0]+" section of time string "+time+" into an hour value of "+copy.getHours()+"<br/>Created date object with value "+copy+"<br/><br/>";
return copy;
}
But it's producing the following date values
Turning 00 section of time string 00:00 into an hour value of 0
Created date object with value Sun Mar 28 0106 00:00:44 GMT+0000 (GMT Standard Time)
Turning 00 section of time string 00:59 into an hour value of 0
Created date object with value Sun Mar 28 0106 00:59:44 GMT+0000 (GMT Standard Time)
Turning 01 section of time string 01:00 into an hour value of 0
Created date object with value Sun Mar 28 0106 00:00:44 GMT+0000 (GMT Standard Time)
Turning 01 section of time string 01:59 into an hour value of 0
Created date object with value Sun Mar 28 0106 00:59:44 GMT+0000 (GMT Standard Time)
Turning 02 section of time string 02:00 into an hour value of 2
Created date object with value Sun Mar 28 0106 02:00:44 GMT+0100 (GMT Daylight Time)
Turning 02 section of time string 02:59 into an hour value of 2
Created date object with value Sun Mar 28 0106 02:59:44 GMT+0100 (GMT Daylight Time)
Turning 03 section of time string 03:00 into an hour value of 3
Created date object with value Sun Mar 28 0106 03:00:44 GMT+0100 (GMT Daylight Time)
Turning 03 section of time string 03:59 into an hour value of 3
Created date object with value Sun Mar 28 0106 03:59:44 GMT+0100 (GMT Daylight Time)
It's only the value for 01:00 that's off in all 24 hours of the day, and it changes the GMT.
The code runs perfectly in internet explorer.
Any help on this front would be appreciated.