public static DateTimeOffset Add(this DateTime dateTime, TimeSpan timeSpan, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { var utc = dateTime.Kind == DateTimeKind.Unspecified ? resolver.Invoke(dateTime, timeZone).UtcDateTime : dateTime.ToUniversalTime(); var dt = utc.Add(timeSpan); return TimeZoneInfo.ConvertTime(dt, timeZone); }
public static DateTimeOffset AddYears(this DateTimeOffset dateTimeOffset, int years, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return AddByDate(dateTimeOffset, dt => dt.AddYears(years), timeZone, resolver); }
public static DateTimeOffset AddMonths(this DateTimeOffset dateTimeOffset, int months, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return AddByDate(dateTimeOffset, dt => dt.AddMonths(months), timeZone, resolver); }
private static DateTimeOffset AddByDate(DateTimeOffset dateTimeOffset, Func<DateTime, DateTime> operation, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { var dto = TimeZoneInfo.ConvertTime(dateTimeOffset, timeZone); var dt = operation.Invoke(dto.DateTime); return resolver.Invoke(dt, timeZone); }
public static DateTimeOffset Add(this DateTime dateTime, TimeSpan timeSpan, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { var utc = dateTime.Kind == DateTimeKind.Unspecified ? resolver.Invoke(dateTime, timeZone).UtcDateTime : dateTime.ToUniversalTime(); var dt = utc.Add(timeSpan); return(TimeZoneInfo.ConvertTime(dt, timeZone)); }
public static DateTimeOffset AddHours(this DateTime dateTime, double hours, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return(dateTime.Add(TimeSpan.FromHours(hours), timeZone, resolver)); }
private static DateTimeOffset AddByDate(DateTime dateTime, Func <DateTime, DateTime> operation, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { if (dateTime.Kind != DateTimeKind.Unspecified) { dateTime = TimeZoneInfo.ConvertTime(dateTime, timeZone); } var result = operation.Invoke(dateTime); return(resolver.Invoke(result, timeZone)); }
public static DateTimeOffset Subtract(this DateTime dateTime, TimeSpan timeSpan, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return(dateTime.Add(timeSpan.Negate(), timeZone, resolver)); }
public static DateTimeOffset AddDays(this DateTime dateTime, int days, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return AddByDate(dateTime, dt => dt.AddDays(days), timeZone, resolver); }
public static DateTimeOffset Subtract(this DateTime dateTime, TimeSpan timeSpan, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return dateTime.Add(timeSpan.Negate(), timeZone, resolver); }
private static DateTimeOffset AddByDate(DateTime dateTime, Func<DateTime, DateTime> operation, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { if (dateTime.Kind != DateTimeKind.Unspecified) { dateTime = TimeZoneInfo.ConvertTime(dateTime, timeZone); } var dt = operation.Invoke(dateTime); return resolver.Invoke(dt, timeZone); }
public static DateTimeOffset AddMonths(this DateTimeOffset dateTimeOffset, int months, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return(AddByDate(dateTimeOffset, dt => dt.AddMonths(months), timeZone, resolver)); }
public static DateTimeOffset AddYears(this DateTimeOffset dateTimeOffset, int years, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return(AddByDate(dateTimeOffset, dt => dt.AddYears(years), timeZone, resolver)); }
private static DateTimeOffset AddByDate(DateTimeOffset dateTimeOffset, Func <DateTime, DateTime> operation, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { var dto = TimeZoneInfo.ConvertTime(dateTimeOffset, timeZone); var dt = operation.Invoke(dto.DateTime); return(resolver.Invoke(dt, timeZone)); }
public static DateTimeOffset AddSeconds(this DateTime dateTime, double seconds, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return(dateTime.Add(TimeSpan.FromSeconds(seconds), timeZone, resolver)); }
public static DateTimeOffset AddHours(this DateTime dateTime, double hours, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return dateTime.Add(TimeSpan.FromHours(hours), timeZone, resolver); }
public static DateTimeOffset AddTicks(this DateTime dateTime, long ticks, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return(dateTime.Add(TimeSpan.FromTicks(ticks), timeZone, resolver)); }
public static DateTimeOffset AddMinutes(this DateTime dateTime, double minutes, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return dateTime.Add(TimeSpan.FromMinutes(minutes), timeZone, resolver); }
public static DateTimeOffset Add(this DateTime dateTime, TimeSpan timeSpan, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { var dto = resolver.Invoke(dateTime, timeZone); var result = dto.Add(timeSpan); return(TimeZoneInfo.ConvertTime(result, timeZone)); }
public static DateTimeOffset AddSeconds(this DateTime dateTime, double seconds, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return dateTime.Add(TimeSpan.FromSeconds(seconds), timeZone, resolver); }
public static DateTimeOffset AddDays(this DateTime dateTime, int days, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return(AddByDate(dateTime, dt => dt.AddDays(days), timeZone, resolver)); }
public static DateTimeOffset AddTicks(this DateTime dateTime, long ticks, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return dateTime.Add(TimeSpan.FromTicks(ticks), timeZone, resolver); }
public static DateTimeOffset AddMinutes(this DateTime dateTime, double minutes, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { return(dateTime.Add(TimeSpan.FromMinutes(minutes), timeZone, resolver)); }
public static DateTimeOffset Add(this DateTime dateTime, TimeSpan timeSpan, TimeZoneInfo timeZone, TimeZoneOffsetResolver resolver) { var dto = resolver.Invoke(dateTime, timeZone); var result = dto.Add(timeSpan); return TimeZoneInfo.ConvertTime(result, timeZone); }