Пример #1
0
 public C_Meeting(string sponsor,
                string participator,
                C_Date startTime,
                C_Date endTime,
                string title)
 {
     sponsor_ = sponsor;
     participator_ = participator;
     startDate_ = startTime;
     endDate_ = endTime;
     title_ = title;
 }
Пример #2
0
        public static C_Date stringToDate(string dateString)
        {
            C_Date temp = new C_Date(0,0,0,0,0);
            int ptr = 5;
            // year
            temp.year_ = (dateString[0] - '0') * 1000 +
               (dateString[1] - '0') * 100 +
               (dateString[2] - '0') * 10 +
               (dateString[3] - '0');
              // month
              if (dateString[6] == '-') {
            temp.month_ = dateString[5] - '0';
            ptr += 2;
              } else {
            temp.month_ = (dateString[5] - '0') * 10 + (dateString[6] - '0');
            ptr += 3;
              }
              // day
              if (dateString[ptr + 1] == '/') {
            temp.day_ = dateString[ptr] - '0';
            ptr += 2;
              } else {
            temp.day_ = (dateString[ptr] - '0') * 10 + (dateString[ptr + 1] - '0');
            ptr += 3;
              }
              // hour
              if (dateString[ptr + 1] == ':') {
            temp.hour_ = dateString[ptr] - '0';
            ptr += 2;
              } else {
            temp.hour_ = (dateString[ptr] - '0') * 10 + (dateString[ptr + 1] - '0');
            ptr += 3;
              }
              // min

              int len = dateString.Length;

              if (ptr + 2 > len) {
            temp.minute_ = dateString[ptr] - '0';
              } else {
            temp.minute_ = (dateString[ptr] - '0') * 10 + (dateString[ptr + 1] - '0');
              }
              return temp;
        }
Пример #3
0
 public static bool isValid(C_Date date)
 {
     // year
     if (date.year_ < 1000 || date.year_ > 9999)
     {
         return false;
     }
     // month
     if (date.month_ < 1 || date.month_ > 12) {
         return false;
     }
     // day
     if (date.month_ != 2)
     {
         if (date.day_ < 0 || date.day_ > t_daylist[date.month_])
         {
             return false;
         }
     }
     else
     {
         if (is_leap_year(date.year_) == true)
         {
             if (date.day_ < 0 || date.day_ > 29)
             {
                 return false;
             }
         }
         else
         {
             if (date.day_ < 0 || date.day_ > 28)
             {
                 return false;
             }
         }
     }
     // hour
     if (date.hour_ < 0 || date.hour_ > 23)
     {
         return false;
     }
     // minute
     if (date.minute_ < 0 || date.minute_ > 59)
     {
         return false;
     }
     return true;
 }
Пример #4
0
 public static string dateToString(C_Date date)
 {
     string tstr = "";
       // year
       int tyear = date.year_;
       tstr += Convert.ToChar(tyear / 1000 + '0');
       tyear = tyear % 1000;
       tstr += Convert.ToChar(tyear / 100 + '0');
       tyear = tyear % 100;
       tstr += Convert.ToChar(tyear / 10 + '0');
       tyear = tyear % 10;
       tstr += Convert.ToChar(tyear + '0');
       tstr += '-';
       // month
       int tmonth = date.month_;
       if (tmonth / 10 < 1) {
     tstr += '0';
     tstr += Convert.ToChar(tmonth + '0');
     tstr += '-';
       } else {
     tstr += Convert.ToChar(tmonth / 10 + '0');
     tstr += Convert.ToChar(tmonth % 10 + '0');
     tstr += '-';
       }
       // day
       int tday = date.day_;
       if (tday / 10 < 1) {
     tstr += '0';
     tstr += Convert.ToChar(tday + '0');
     tstr += '/';
       } else {
     tstr += Convert.ToChar(tday / 10 + '0');
     tstr += Convert.ToChar(tday % 10 + '0');
     tstr += '/';
       }
       // hour
       int thour = date.hour_;
       if (thour / 10 < 1) {
     tstr += '0';
     tstr += Convert.ToChar(thour + '0');
     tstr += ':';
       } else {
     tstr += Convert.ToChar(thour / 10 + '0');
     tstr += Convert.ToChar(thour % 10 + '0');
     tstr += ':';
       }
       // minute
       int tmin = date.minute_;
       if (tmin / 10 < 1) {
     tstr += '0';
     tstr += Convert.ToChar(tmin + '0');
       } else {
     tstr += Convert.ToChar(tmin / 10 + '0');
     tstr += Convert.ToChar(tmin % 10 + '0');
       }
       // over
       tstr += '\0';
       return tstr;
 }
Пример #5
0
 public bool addMeeting(string sponsor,
                        string participator,
                        C_Date stime,
                        C_Date etime,
                        string title)
 {
     if (!C_Date.isValid(stime) || !C_Date.isValid(etime))
     {
         return false;
     }
     foreach (C_Meeting iter in meetings_)
     {
         if (iter.getSponsor() == sponsor &&
             ((iter.getStartDate() > stime && iter.getStartDate() < etime) ||
             (iter.getEndDate() > stime && iter.getEndDate() < etime) ||
             (iter.getStartDate() < stime && iter.getEndDate() > etime) ||
             (iter.getStartDate() > stime && iter.getEndDate() < etime))
             )
         {
                 return false;
         }
         else if (iter.getParticipator() == sponsor &&
                 ((iter.getStartDate() > stime && iter.getStartDate() < etime) ||
                 (iter.getEndDate() > stime && iter.getEndDate() < etime) ||
                 (iter.getStartDate() < stime && iter.getEndDate() > etime) ||
                 (iter.getStartDate() > stime && iter.getEndDate() < etime))
                 )
         {
             return false;
         }
         else if (iter.getSponsor() == participator &&
                 ((iter.getStartDate() > stime && iter.getStartDate() < etime) ||
                 (iter.getEndDate() > stime && iter.getEndDate() < etime) ||
                 (iter.getStartDate() < stime && iter.getEndDate() > etime) ||
                 (iter.getStartDate() > stime && iter.getEndDate() < etime))
             )
         {
             return false;
         }
         else if (iter.getParticipator() == participator &&
                 ((iter.getStartDate() > stime && iter.getStartDate() < etime) ||
                 (iter.getEndDate() > stime && iter.getEndDate() < etime) ||
                 (iter.getStartDate() < stime && iter.getEndDate() > etime) ||
                 (iter.getStartDate() > stime && iter.getEndDate() < etime))
             )
         {
             return false;
         }
             else if (stime > etime)
         {
             return false;
         }
         else if (iter.getTitle() == title)
         {
             return false;
         }
     }
     C_Meeting t_node = new C_Meeting(sponsor, participator, stime, etime, title);
     meetings_.Add(t_node);
     return true;
 }
Пример #6
0
 public List<C_Meeting> queryMeetingsByTime(string userName,
                                          C_Date stime,
                                          C_Date etime)
 {
     List<C_Meeting> t_list = new List<C_Meeting>();
     foreach (C_Meeting iter in meetings_) {
         if ((iter.getSponsor() == userName ||
             iter.getParticipator() == userName) &&
             !(iter.getEndDate() < stime ||
             iter.getStartDate() > etime))
         {
             t_list.Add(iter);
         }
     }
     return t_list;
 }
Пример #7
0
 public void setStartDate(C_Date startTime)
 {
     startDate_ = startTime;
 }
Пример #8
0
 public void setEndDate(C_Date endTime)
 {
     endDate_ = endTime;
 }