Esempio n. 1
0
        private int AddTagValues(Tag tag, IList <Token> toks, int tpos)
        {
            int count = toks.Count;
            int index;

            for (index = tpos; index < count; ++index)
            {
                Token token = toks[index];
                if (token.literal)
                {
                    if (token.type == Type.DATE && index + 1 < count && toks[index + 1].type == Type.TIME)
                    {
                        SDLDateTime      dt   = (SDLDateTime)token.GetObjectForLiteral();
                        TimeSpanWithZone tswz = (TimeSpanWithZone)toks[index + 1].GetObjectForLiteral();
                        if (tswz.Days != 0)
                        {
                            tag.AddValue((object)dt);
                            tag.AddValue((object)new TimeSpan(tswz.Days, tswz.Hours, tswz.Minutes, tswz.Seconds, tswz.Milliseconds));
                            if (tswz.TimeZone != null)
                            {
                                this.ParseException("TimeSpan cannot have a timezone", token.line, token.position);
                            }
                        }
                        else
                        {
                            tag.AddValue((object)Parser.Combine(dt, tswz));
                        }
                        ++index;
                    }
                    else
                    {
                        object objectForLiteral = token.GetObjectForLiteral();
                        if (objectForLiteral is TimeSpanWithZone)
                        {
                            TimeSpanWithZone timeSpanWithZone = (TimeSpanWithZone)objectForLiteral;
                            if (timeSpanWithZone.TimeZone != null)
                            {
                                this.ExpectingButGot("TIME SPAN", (object)"TIME (component of date/time)", token.line, token.position);
                            }
                            tag.AddValue((object)new TimeSpan(timeSpanWithZone.Days, timeSpanWithZone.Hours, timeSpanWithZone.Minutes, timeSpanWithZone.Seconds, timeSpanWithZone.Milliseconds));
                        }
                        else
                        {
                            tag.AddValue(objectForLiteral);
                        }
                    }
                }
                else if (token.type != Type.IDENTIFIER)
                {
                    this.ExpectingButGot("LITERAL or IDENTIFIER", (object)token.type, token.line, token.position);
                }
                else
                {
                    break;
                }
            }
            return(index);
        }
Esempio n. 2
0
 private static SDLDateTime Combine(SDLDateTime dt, TimeSpanWithZone tswz)
 {
     return new SDLDateTime(dt.Year, dt.Month, dt.Day, tswz.Hours, tswz.Minutes, tswz.Seconds, tswz.Milliseconds, tswz.TimeZone);
 }