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); }
public SDLDateTime(DateTime dateTime, string timeZone) { this.dateTime = dateTime; if (timeZone == null) { timeZone = SDLDateTime.getCurrentTimeZone(); } this.timeZone = timeZone; }
public override string ToString() { StringBuilder stringBuilder = new StringBuilder((string)(object)this.Year + (object)"/"); if (this.Month < 10) { stringBuilder.Append("0"); } stringBuilder.Append((string)(object)this.Month + (object)"/"); if (this.Day < 10) { stringBuilder.Append("0"); } stringBuilder.Append(this.Day); if (this.HasTime) { stringBuilder.Append(" "); if (this.Hour < 10) { stringBuilder.Append("0"); } stringBuilder.Append(this.Hour); stringBuilder.Append(":"); if (this.Minute < 10) { stringBuilder.Append("0"); } stringBuilder.Append(this.Minute); if (this.Second != 0 || this.Millisecond != 0) { stringBuilder.Append(":"); if (this.Second < 10) { stringBuilder.Append("0"); } stringBuilder.Append(this.Second); if (this.Millisecond != 0) { stringBuilder.Append("."); string str = string.Concat((object)this.Millisecond); if (str.Length == 1) { str = "00" + str; } else if (str.Length == 2) { str = "0" + str; } stringBuilder.Append(str); } } stringBuilder.Append("-"); stringBuilder.Append(this.TimeZone == null ? SDLDateTime.getCurrentTimeZone() : this.TimeZone); } return(((object)stringBuilder).ToString()); }
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); }