Exceptionless.DateTimeExtensions
Exceptionless.DateTimeExtensions copied to clipboard
SubtractSaturating
trafficstars
public static class TimeSpanExtensions {
public static TimeSpan SubtractSaturating(this TimeSpan self, TimeSpan other) =>
self >= other ? self.Subtract(other) : TimeSpan.Zero;
}
This is a method that subtracts a TimeSpan and is just ensuring that the resulting TimeSpan doesn't go below zero?
yes.
Isn't this the same as safe subtract that we have for datetimes?
@dzmitry-lahoda ^^