public string convertTime(string aTime)
        {
            try
            {
                string[] timeParts = aTime.Split(':');

                int hours   = int.Parse(timeParts[0]);
                int minutes = int.Parse(timeParts[1]);
                int seconds = int.Parse(timeParts[2]);

                if (hours > 24 || minutes > 59 || seconds > 59)
                {
                    throw new Exception();
                }

                BerlinUhr clock = new BerlinUhr();

                clock.Hour    = hours.ToString();
                clock.Minute  = minutes.ToString();
                clock.Seconds = seconds.ToString();

                return(clock.ToString());
            }
            catch
            {
                return("Invalid time format.");
            }
        }
示例#2
0
        public string convertTime(string aTime)
        {
            if (!string.IsNullOrEmpty(ValidateInput(aTime)))
            {
                return("Problem with input! pattern example 00:00:00");
            }

            BerlinUhr oClock = new BerlinUhr(aTime);

            return(oClock.BuildUpBerlinClock());
        }
        public string ConvertTime(string time)
        {
            if (string.IsNullOrWhiteSpace(time))
            {
                throw new ArgumentNullException(nameof(time));
            }

            var dateTime = BerlinUhrTimeSpanConverter.Parse(time);

            var clock = new BerlinUhr(dateTime);

            return(clock.ToString());
        }