zoukankan      html  css  js  c++  java
  • [ST2017] Hw1: An error from my past projects [Deadline: 23:59:59, Feb.27, 2017]

    3014218071 王漢超

    my blog: http://www.cnblogs.com/cragoncanth/

    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.

    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.

    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;

    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.

    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;

    As solved this problem.

    其他错误一擇

    IE7 YouTube 用户长时观看视频并四处移动鼠标 CSS会使操作变慢并搞垮浏览器 未释放的指针和资源

  • 相关阅读:
    EXT2
    Ext.DomQuery

    spring.net+nhibernate
    网址
    一句代码就解决一个开发中常见的小bug....
    Swift 已经正式开源了! 你了解到了吗?
    [知识点随笔] UIView--transform 属性
    懒加载(延迟加载)之后,在使用数据过程中容易出现的bug
    java设计模式
  • 原文地址:https://www.cnblogs.com/cragoncanth/p/6473382.html
Copyright © 2011-2022 走看看