Пример #1
0
        public static Timezone Parse(string timezone)
        {
            // Format +530 or -530
            var match = Pattern.Match(timezone);

            if (match.Success == false)
            {
                throw new ArgumentException(timezone + " is not a valid Timezone value.");
            }
            var  hour = int.Parse(match.Groups["hour"].Value);
            uint min  = uint.Parse(match.Groups["min"].Value);

            return(Timezone.Create(hour, min));
        }
Пример #2
0
 public static bool TryParse(string timezone, out Timezone zone)
 {
     zone = null;
     try
     {
         // Format +530 or -530
         var match = Pattern.Match(timezone);
         if (match.Success == false)
         {
             return(false);
         }
         var hour = int.Parse(match.Groups["hour"].Value);
         var min  = uint.Parse(match.Groups["min"].Value);
         zone = Timezone.Create(hour, min);
         return(true);
     }
     catch
     {
         zone = null;
         return(false);
     }
 }