3014218071 王漢超git
my blog: http://www.cnblogs.com/cragoncanth/github
my git: https://github.com/E-C-Ares/TJUSCS2017瀏覽器
Q: Briefly describe an error from your past projects that you have recently completed or an error from other projects which impress you most. State the reason, impact of the error and how did you find it.less
A: There is an error from my past project that I have recently completed. The project is called 'ToDoList on Web', which is a Web-Page-Application linked to the remote database. And the error is displaying the wrong date.this
The reason of that is the date is in a form of string, so it can't be increased by simply adding 1 on it: date(x + 1) ≠ date(x) + 1;spa
The impact of the error is that the end number of date is just increased by 1 regardless of the range of the date.指針
I find it as the date has show 16-12-32 and 17-01-010.orm
Then I wrote a change-function:視頻
var time=data[i].deadline.split('T')[0];
//var cha=time.charAt(time.length-1);
//cha=parseInt(cha)+1;
var yearFlag = 0;
var yearad = time.substring(0,4);
yearad = parseInt(yearad);
/*判斷閏年*/
if((yearad%4 == 0)&&((yearad%100 != 0)||(yearad%400 == 0)))
yearFlag = 1;
//alert(yearFlag);
//time=time.substring(0,time.length-1)+cha;
/*time加一天, 必須用其餘變量存*/
var s1 = time[0];
var s2 = time[1];
var s3 = time[2];
var s4 = time[3];
var s5 = time[5];
var s6 = time[6];
var s7 = time[8];
var s8 = time[9];
if((yearFlag == 1)&&(time[5]==0)&&(time[6]==2)&&(time[8]==2)&&(time[9]==9))
{
//閏年2月29
s6 = 2; //time[6] = 3;
s7 = 0; //time[8] = 0;
s8 = 1; //time[9] = 1;
}
else if((yearFlag == 0)&&(time[5]==0)&&(time[6]==2)&&(time[8]==2)&&(time[9]==8))
{
//平年2月28
s6 = 3; //time[6] = 3;
s7 = 0; //time[8] = 0;
s8 = 1; //time[9] = 1;
}
else if((time[5]==1)&&(time[6]==2)&&(time[8]==3)&&(time[9]==1)){
//12月31日
s5 = 0; //time[5] = 0;
s6 = 1; //time[6] = 1;
s7 = 0; //time[8] = 0;
s8 = 1; //time[9] = 1;
if(time[3] == 9)
{
s4 = 0; //time[3] = 0;
if(time[2] == 9){
s3 = 0; //time[2] = 0;
if(time[1] == 9){
s2 = 0; //time[1] = 0;
s1 = parseInt(s1) + 1; //time[0] = parseInt(time[0]) + 1;
}
else{
s2 = parseInt(s2) + 1; //time[1] = parseInt(time[1]) + 1;
}
}
else{
s3 = parseInt(s3) + 1; //time[2] = parseInt(time[2]) + 1;
}
}
s4 = parseInt(s4) + 1; //time[3] = parseInt(time[3]) + 1;
}
else if(time[9] == 9){
s7 = parseInt(s7) + 1; //time[8] = parseInt(time[8]) + 1;
s8 = 0; //time[9] = 0;
}
else if((time[6] == 9)&&(time[8] == 3)){
//9月30
s5 = 1; //time[5] = 1;
s6 = 0; //time[6] = 0;
s7 = 0; //time[8] = 0;
s8 = 1; //time[9] = 1;
}
else if(time[8] == 3){
//30 31
if((time[9] == 1)||(time[6] == 4)||(time[6] == 6)||(time[6] == 9)||((time[5] == 1)&&(time[6] == 1))){
s6 = parseInt(s6) + 1; //time[6] = parseInt(time[6]) + 1;
s7 = 0; //time[8] = 0;
s8 = 1; //time[9] = 1;
}
else{
s8 = parseInt(s8) + 1; //time[9] = parseInt(time[9]) + 1;
}
}
else{
s8 = parseInt(s8) + 1; //time[9] = parseInt(time[9]) + 1;
}
time = s1 + s2 + s3 + s4 + "-" + s5 + s6 + "-" + s7 + s8; blog
As solved this problem.
其餘錯誤一擇
IE7 YouTube 用戶長時觀看視頻並四處移動鼠標 CSS會使操做變慢並搞垮瀏覽器 未釋放的指針和資源