Esempio n. 1
0
        public override bool Equals(object obj)
        {
            DayTime other = obj as DayTime;

            if (other == null)
            {
                return(false);
            }
            return(other.Hour == Hour &&
                   other.Minute == Minute &&
                   other.Second == Second);
        }
Esempio n. 2
0
        public static bool TryParse(string time, out DayTime dayTime)
        {
            dayTime = null;
            if (time == null || time.Trim().Length == 0)
            {
                return(false);
            }

            string[] parts = time.Split(':');

            if (parts.Length < 2)
            {
                return(false);
            }

            int hh, mm, ss = 0;

            if (!int.TryParse(parts[0], out hh))
            {
                return(false);
            }
            if (!int.TryParse(parts[1], out mm))
            {
                return(false);
            }

            if (parts.Length > 2)
            {
                if (!int.TryParse(parts[2], out ss))
                {
                    return(false);
                }
            }

            dayTime = new DayTime(hh, mm, ss);
            return(true);
        }