internal static DateTime EnsureDateTime(DateTime value, DateTimeZoneHandling timeZone) { switch (timeZone) { case DateTimeZoneHandling.Local: { value = DateTimeUtils.SwitchToLocalTime(value); return(value); } case DateTimeZoneHandling.Utc: { value = DateTimeUtils.SwitchToUtcTime(value); return(value); } case DateTimeZoneHandling.Unspecified: { value = new DateTime(value.Ticks, DateTimeKind.Unspecified); return(value); } case DateTimeZoneHandling.RoundtripKind: { return(value); } default: { throw new ArgumentException("Invalid date time handling value."); } } }