private object GetValueForDateTimeDataValueType(DateTime dateTimeValue, DateTimeValueKind kind, TimeZoneInfo timeZoneOffset) { switch (kind) { case DateTimeValueKind.Date: return(dateTimeValue.Date); case DateTimeValueKind.Time: return(dateTimeValue); case DateTimeValueKind.DateTime: return(TimeZoneInfo.ConvertTimeToUtc(dateTimeValue, timeZoneOffset)); default: return(dateTimeValue); } }
private object FormatDateTimeValue(object value, DateTimeValueKind kind) { var dateTimeValue = value is TimeSpan ? new DateTime(((TimeSpan)value).Ticks) : (DateTime)value; switch (kind) { case DateTimeValueKind.Date: return(dateTimeValue.Date); case DateTimeValueKind.DateTime: var curentUserTimeZone = UserConnection.CurrentUser.TimeZone ?? TimeZoneInfo.Utc; return(TimeZoneInfo.ConvertTimeToUtc(dateTimeValue, curentUserTimeZone)); case DateTimeValueKind.Time: default: return(dateTimeValue); } }