Exemple #1
0
 public void SetTimeTo(_TCTime tme)
 {
     this.hour = tme.hour;
     this.min = tme.min;
 }
Exemple #2
0
    public void CalTimeDuration(_TCTime tme)
    {
        _TCTime end = new _TCTime();

        // สลับเวลามาก มาไว้ที่ ตัวเอง(this)  เวลาน้อย ไปไว้ที่ end
        if (this.CompareWith(tme)>=0)
        {
            end.SetTimeTo(tme);
        }
        else
        {
            end.SetTimeTo(this);
            this.SetTimeTo(tme);
        }
        // ลบเวลา
        this.hour -= end.hour;
        this.min -= end.min;
        // ปรับ ชม./นาที
        if (this.min<=0)
        {
            this.hour--;
            this.min += 60;
        }
        if (this.hour < 0)
        {
            this.hour = 0;
        }
    }
Exemple #3
0
    // Compare Time to Other ==> Return -1=น้อยกว่า, 0=เท่ากัน, 1=มากกว่า
    public int CompareWith(_TCTime cmp)
    {
        int ret=0;
        if (this.hour < cmp.hour)  // ชม.น้อยกว่า
        {
            ret = -1;
        }
        else if (this.hour == cmp.hour) // ชม.เท่ากัน
        {
            if (this.min < cmp.min)     // ชม.เท่ากัน + นาทีน้อยกว่า
            {
                ret = -1;
            }
            else if (this.min > cmp.min)    // ชม.เท่ากัน + นาทีมากกว่า
            {
                ret = 1;
            }
            else    // ชม.เท่ากัน + นาทีเท่ากัน
            {
                ret = 0;
            }

        }
        else    // ชม.มากกว่า
        {
            ret = 1;
        }
        return ret;
    }
Exemple #4
0
 public void AddTimeDuration(_TCTime duration)
 {
     this.hour += duration.hour;
     this.min += duration.min;
     if (this.min >= 60)
     {
         this.hour++;
         this.min -= 60;
     }
 }