Exemplo n.º 1
0
        public TaskDetails()
        {
            id       = eventname = location = startime = endtime = duration = endDate = endRepeat = "null";
            repeat   = "0D";
            reminder = "1H";
            priority = "medium";
            repeat   = "none";
            Conversions objectConversions = new Conversions();
            string      SystemDate        = objectConversions.ConvertSystemDateToddmmyyyy();

            startDate = SystemDate;
        }
Exemplo n.º 2
0
        public string CheckDate(string s)
        {
            try
            {
                checkIfTimeFormat(s);
                if (errorMessage != null)
                {
                    return(errorMessage);
                }
                //replace '-' '.' ',' and '\' with '/'

                for (int i = 0; i < s.Trim().Length; i++)
                {
                    if (!char.IsDigit(s[i]))
                    {
                        s = s.Replace(s[i].ToString(), "/");
                    }
                }
                //remove extra special characters..example // or .. etc
                string[] s_date = s.Split('/');
                string   s_temp = null;
                if ((s_date[s_date.Count() - 1]) == "")
                {
                    s_date[s_date.Count() - 1] = System.DateTime.Today.Year.ToString();
                }
                else if (s_date.Count() == 2)
                {
                    s     += "/" + System.DateTime.Today.Year.ToString();
                    s_date = s.Trim().Split('/');
                }
                if (s_date.Count() != 3)
                {
                    errorMessage = INVALIDVALUE;
                    return(errorMessage);
                }
                int k = 0;
                for (int i = 0; i < s_date.Count(); i++)
                {
                    if (s_date[i] == "")
                    {
                        errorMessage = INVALIDVALUE;
                        return(errorMessage);
                    }
                    s_temp += s_date[i];
                    k++;
                    if (k <= 2)
                    {
                        s_temp += "/";
                    }
                }
                if (s_temp != null)
                {
                    s = s_temp;
                }
                s = CheckForValidDateAndMonth(s);
                Conversions objectConversions = new Conversions();
                if (errorMessage != null)
                {
                    return(errorMessage);
                }
                if (objectConversions.ConvertStringToDate(s).CompareTo((objectConversions.ConvertStringToDate(objectConversions.ConvertSystemDateToddmmyyyy()))) < 0)
                {
                    s = objectConversions.ConvertSystemDateToddmmyyyy();
                }
                return(s);
            }
            catch (Exception e)
            {
                StreamWriter loggingWriter = new StreamWriter("Logging.txt");
                loggingWriter.WriteLine(System.DateTime.Now + e.Message + "\n");
                loggingWriter.Close();
                errorMessage = "error!";
                return(errorMessage);
            }
        }