예제 #1
0
        public override bool TryParse(string value, ref object obj)
        {
            UTC_Offset utco  = (UTC_Offset)obj;
            Match      match = Regex.Match(value, @"(\+|-)(\d{2})(\d{2})(\d{2})?");

            if (match.Success)
            {
                try
                {
                    if (match.Groups[0].Value == "+")
                    {
                        utco.Positive = true;
                    }
                    utco.Hours   = Int32.Parse(match.Groups[2].Value);
                    utco.Minutes = Int32.Parse(match.Groups[3].Value);
                    if (match.Groups[4].Success)
                    {
                        utco.Seconds = Int32.Parse(match.Groups[4].Value);
                    }
                }
                catch
                {
                    return(false);
                }
                return(true);
            }

            return(false);
        }
예제 #2
0
        public override bool TryParse(string value, ref object obj)
        {
            UTC_Offset utco  = (UTC_Offset)obj;
            Match      match = Regex.Match(value, @"(\+|-)(\d{2})(\d{2})(\d{2})?");

            if (match.Success)
            {
                try
                {
                    // NOTE: Fixes bug #1874174 - TimeZone positive UTC_Offsets don't parse correctly
                    if (match.Groups[1].Value == "+")
                    {
                        utco.Positive = true;
                    }
                    utco.Hours   = Int32.Parse(match.Groups[2].Value);
                    utco.Minutes = Int32.Parse(match.Groups[3].Value);
                    if (match.Groups[4].Success)
                    {
                        utco.Seconds = Int32.Parse(match.Groups[4].Value);
                    }
                }
                catch
                {
                    return(false);
                }
                return(true);
            }

            return(false);
        }
예제 #3
0
 public override void CopyFrom(object obj)
 {
     if (obj is UTC_Offset)
     {
         UTC_Offset utco = (UTC_Offset)obj;
         this.Positive = utco.Positive;
         this.Hours    = utco.Hours;
         this.Minutes  = utco.Minutes;
         this.Seconds  = utco.Seconds;
     }
 }
예제 #4
0
        public override bool Equals(object obj)
        {
            UTC_Offset o = obj as UTC_Offset;

            if (o != null)
            {
                return(object.Equals(Positive, o.Positive) &&
                       object.Equals(Hours, o.Hours) &&
                       object.Equals(Minutes, o.Minutes) &&
                       object.Equals(Seconds, o.Seconds));
            }
            return(base.Equals(obj));
        }