public static TzDbZoneContinuation Parse(Queue <Token> unProcessedTokens, String timeZoneName)
        {
            try
            {
                TimeSpan gmtOff = TimeSpanExpression.Parse(unProcessedTokens);
                string   rules  = unProcessedTokens.Dequeue().Value;
                TimeZoneAbbreviationFormat format =
                    TimeZoneAbbreviationFormatExpression.Parse(unProcessedTokens);
                // until is optional
                TzDbAbstractDateTime until;
                TzDbDateTimeExpression.TryParse(unProcessedTokens, out until);

                Token endLineToken = unProcessedTokens.Dequeue();
                // guard end of line token was present
                if (endLineToken.TokenType != TokenType.EndLine)
                {
                    string msg = String.Format(
                        "received unexpected token type:{0} when token type should have been {1}",
                        endLineToken.TokenType, TokenType.EndLine);
                    throw new Exception(msg);
                }

                return(new TzDbZoneContinuation(gmtOff, rules, format, until));
            }
            catch (Exception e)
            {
                throw new Exception("Error occured while parsing zone continuation expression", e);
            }
        }
예제 #2
0
 public TzDbZoneContinuation(TimeSpan gmtOff, String rules, TimeZoneAbbreviationFormat format,
                             TzDbAbstractDateTime until = null)
     : this()
 {
     Gmtoff = gmtOff;
     Rules  = rules;
     Format = format;
     Until  = until;
 }
예제 #3
0
        public override string GetTimeZoneAbbreviation(TimeSpan standardOffset, TimeZoneAbbreviationFormat format,
                                                       Moment moment)
        {
            DaylightSavingsRule effectiveRule;

            if (TryGetMostRecentDaylightSavingsRule(standardOffset, moment, out effectiveRule))
            {
                return(String.Format(format.Format, effectiveRule.TimeZoneAbbreviationVariable.Value));
            }

            return(format.Format);
        }
 public TimeZoneImplementation(
     Moment effectiveTo,
     TimeSpan standardUtcOffset,
     AbstractDaylightSavingsAdjustment daylightSavingsAdjustment,
     TimeZoneAbbreviationFormat timeZoneAbbreviationFormat,
     Guid?id = null)
 {
     EffectiveTo                = effectiveTo;
     StandardUtcOffset          = standardUtcOffset;
     DaylightSavingsAdjustment  = daylightSavingsAdjustment;
     TimeZoneAbbreviationFormat = timeZoneAbbreviationFormat;
     Id = id ?? Guid.NewGuid();
 }
예제 #5
0
        public static bool TryParse(Queue <Token> unProcessedTokens, out TzDbZone?tzDbZone)
        {
            // the value of the first token of every link entry is Link
            const String linkRegex = "Zone";

            if (Regex.IsMatch(unProcessedTokens.Peek().Value, linkRegex))
            {
                try
                {
                    // dequeue Zone token and discard
                    unProcessedTokens.Dequeue();

                    string   ianaId = unProcessedTokens.Dequeue().Value;
                    TimeSpan gmtOff = TimeSpanExpression.Parse(unProcessedTokens);
                    string   rules  = unProcessedTokens.Dequeue().Value;
                    TimeZoneAbbreviationFormat format = TimeZoneAbbreviationFormatExpression.Parse(unProcessedTokens);
                    // until is optional
                    TzDbAbstractDateTime until;
                    TzDbDateTimeExpression.TryParse(unProcessedTokens, out until);

                    tzDbZone = new TzDbZone(gmtOff, rules, format, ianaId, until);

                    Token endLineToken = unProcessedTokens.Dequeue();
                    // guard end of line token was present
                    if (endLineToken.TokenType != TokenType.EndLine)
                    {
                        string msg = String.Format(
                            "received unexpected token type:{0} when token type should have been {1}",
                            endLineToken.TokenType, TokenType.EndLine);
                        throw new Exception(msg);
                    }

                    return(true);
                }
                catch (Exception e)
                {
                    throw new Exception("Error occured while parsing zone expression", e);
                }
            }

            tzDbZone = null;
            return(false);
        }
 public override string GetTimeZoneAbbreviation(TimeSpan standardOffset, TimeZoneAbbreviationFormat format,
                                                Moment moment)
 {
     return(String.Format(format.Format));
 }
예제 #7
0
 public abstract String GetTimeZoneAbbreviation(TimeSpan standardOffset, TimeZoneAbbreviationFormat format,
                                                Moment moment);