public void ConversionRoundTrip() { Duration second = Duration.FromSeconds(1); AssertEx.EqualTolerance(1, Duration.FromDays(second.Days).Seconds, DaysTolerance); AssertEx.EqualTolerance(1, Duration.FromHours(second.Hours).Seconds, HoursTolerance); AssertEx.EqualTolerance(1, Duration.FromMicroseconds(second.Microseconds).Seconds, MicrosecondsTolerance); AssertEx.EqualTolerance(1, Duration.FromMilliseconds(second.Milliseconds).Seconds, MillisecondsTolerance); AssertEx.EqualTolerance(1, Duration.FromMinutes(second.Minutes).Seconds, MinutesTolerance); AssertEx.EqualTolerance(1, Duration.FromMonths30(second.Months30).Seconds, Months30Tolerance); AssertEx.EqualTolerance(1, Duration.FromNanoseconds(second.Nanoseconds).Seconds, NanosecondsTolerance); AssertEx.EqualTolerance(1, Duration.FromSeconds(second.Seconds).Seconds, SecondsTolerance); AssertEx.EqualTolerance(1, Duration.FromWeeks(second.Weeks).Seconds, WeeksTolerance); AssertEx.EqualTolerance(1, Duration.FromYears365(second.Years365).Seconds, Years365Tolerance); }
/// <inheritdoc cref="Duration.FromMicroseconds(double?)"/> public static Duration?Microseconds(this decimal?value) => Duration.FromMicroseconds(value == null ? (double?)null : Convert.ToDouble(value.Value));
/// <inheritdoc cref="Duration.FromMicroseconds(double)"/> public static Duration Microseconds(this decimal value) => Duration.FromMicroseconds(Convert.ToDouble(value));
/// <inheritdoc cref="Duration.FromMicroseconds(double?)"/> public static Duration?Microseconds(this float?value) => Duration.FromMicroseconds(value);
/// <inheritdoc cref="Duration.FromMicroseconds(double?)"/> public static Duration?Microseconds(this double?value) => Duration.FromMicroseconds(value);
/// <inheritdoc cref="Duration.FromMicroseconds(double)"/> public static Duration Microseconds(this long value) => Duration.FromMicroseconds(value);
public static Duration Microseconds <T>(this T value) => Duration.FromMicroseconds(Convert.ToDouble(value));
public void NumberToMicrosecondsTest() => Assert.Equal(Duration.FromMicroseconds(2), 2.Microseconds());
public static Duration?Microseconds <T>(this T?value) where T : struct => Duration.FromMicroseconds(value == null ? (double?)null : Convert.ToDouble(value.Value));