Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubtractSaturating #43

Open
dzmitry-lahoda opened this issue Dec 9, 2021 · 4 comments
Open

SubtractSaturating #43

dzmitry-lahoda opened this issue Dec 9, 2021 · 4 comments

Comments

@dzmitry-lahoda
Copy link

public static class TimeSpanExtensions {
        public static TimeSpan SubtractSaturating(this TimeSpan self, TimeSpan other) =>
            self >= other ? self.Subtract(other) : TimeSpan.Zero;
    }
@ejsmith
Copy link
Member

ejsmith commented Dec 9, 2021

This is a method that subtracts a TimeSpan and is just ensuring that the resulting TimeSpan doesn't go below zero?

@dzmitry-lahoda
Copy link
Author

yes.

@niemyjski
Copy link
Member

niemyjski commented Dec 9, 2021

Isn't this the same as safe subtract that we have for datetimes?

@niemyjski
Copy link
Member

@dzmitry-lahoda ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants