// This method is for performance. It only update the UTC offset on weekend boundaries. private long GetUtcOffset(TimeStamp tickTime) { if (tickTime.Internal >= nextOffsetUpdate.Internal) { if (timeZone == null) { timeZone = new SymbolTimeZone(symbol); timeZone.SetExchangeTimeZone(); } utcOffset = timeZone.UtcOffset(tickTime); nextOffsetUpdate = utcTime; int dayOfWeek = nextOffsetUpdate.GetDayOfWeek(); nextOffsetUpdate.AddDays(7 - dayOfWeek); nextOffsetUpdate.SetDate(nextOffsetUpdate.Year, nextOffsetUpdate.Month, nextOffsetUpdate.Day); } return(utcOffset); }
/// <inheritdoc/> public void SetTime(TimeStamp utcTime) { binary.UtcTime = utcTime.Internal; if (utcTime.Internal >= nextUtcOffsetUpdate.Internal) { if (timeZone == null) { if (binary.Symbol == 0) { throw new ApplicationException("Please call SetSymbol() prior to SetTime() method."); } SymbolInfo symbol = Factory.Symbol.LookupSymbol(binary.Symbol); timeZone = new SymbolTimeZone(symbol); } utcOffset = timeZone.UtcOffset(UtcTime); nextUtcOffsetUpdate = utcTime; int dayOfWeek = nextUtcOffsetUpdate.GetDayOfWeek(); nextUtcOffsetUpdate.AddDays(7 - dayOfWeek); nextUtcOffsetUpdate.SetDate(nextUtcOffsetUpdate.Year, nextUtcOffsetUpdate.Month, nextUtcOffsetUpdate.Day); } localTime = new TimeStamp(binary.UtcTime); localTime.AddSeconds(utcOffset); }