Ejemplo n.º 1
0
        public void ValidPositiveTimeZone_ParsedTimeZone()
        {
            string timeZone = "+3:45";

            var actualTimeZone = _parser.ParseTimeZone(timeZone);

            Assert.IsTrue(actualTimeZone.Hours == 3 &&
                          actualTimeZone.Minutes == 45 &&
                          actualTimeZone.TimeZoneSign == 1);
        }
        private TimeZone ParseTimeZone(string timeZone)
        {
            if (timeZone == null)
            {
                throw new ArgumentNullException($"{nameof(timeZone)} is null");
            }

            TimeZone tz;

            try
            {
                tz = dateTimeParser.ParseTimeZone(timeZone);
            }
            catch (InvalidTimeZoneFormatException) { throw; }
            catch (ArgumentNullException) { throw; }
            catch (Exception ex)
            {
                throw new TimeConverterException($"Cannot parse {nameof(timeZone)}", ex);
            }

            return(tz);
        }