public virtual void encodeTime(DateTime time)
{
if (time == null)
{
write(edsNull);
return;
}
long milliSecondsSinceMidnight = (long)(time.ToUniversalTime().TimeOfDay.TotalMilliseconds);
TimeZone tz = TimeZone.CurrentTimeZone;
if (tz.IsDaylightSavingTime(time))
{
System.Globalization.DaylightTime period = tz.GetDaylightChanges(time.Year);
milliSecondsSinceMidnight += (long)period.Delta.TotalMilliseconds;
}
int count = byteCount(milliSecondsSinceMidnight);
// unlike other int types which have 8 bytes we only have 4 bytes to encode time
if (count > (edsTimeLen4 - edsTimeLen0))
{
throw new NuoDbSqlException(String.Format("Unable to encode \"{0}\". Need {1} bytes to encode but only have {2} bytes.", time, count, edsTimeLen4 - edsTimeLen0));
}
write(edsTimeLen0 + count);
for (int shift = (count - 1) * 8; shift >= 0; shift -= 8)
{
write((int)(milliSecondsSinceMidnight >> shift));
}
}