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 dto    = resolver.Invoke(dateTime, timeZone);
            var result = dto.Add(timeSpan);

            return(TimeZoneInfo.ConvertTime(result, timeZone));
        }
Example #3
0
        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);
        }
Example #4
0
        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));
        }
        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));
        }
 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);
 }
Example #7
0
        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);
        }
Example #8
0
 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);
 }