Exemple #1
0
        internal static DateTime EnsureDateTime(DateTime value, DateTimeZoneHandling timeZone)
        {
            switch (timeZone)
            {
            case DateTimeZoneHandling.Local:
                value = JsonConvert.SwitchToLocalTime(value);
                goto case 3;

            case DateTimeZoneHandling.Utc:
                value = JsonConvert.SwitchToUtcTime(value);
                goto case 3;

            case DateTimeZoneHandling.Unspecified:
                value = new DateTime(value.Ticks, DateTimeKind.Unspecified);
                goto case 3;

            case DateTimeZoneHandling.RoundtripKind:
                return(value);

            default:
                throw new ArgumentException("Invalid date time handling value.");
            }
        }