Does anyone have any suggestions to potentially improve and make this function work better?
I have a function that basically is supposed to look for gaps for a specified duration on a desired day. I'm looking for ways to improve this and I'm also open for suggestions if there's a completely better way to do this. Even if its some magical linq query.
I call the code using this and then also sort it by how close it is to the specified time that I am looking for.
I know for a fact there is probably a better way to do this and im open for suggestions. Thanks 🙂
I am using the TimePeriodLibrary.NET currently.
2 Replies
Why are you casting minutes to decimal? Time types already have more precise integer values like seconds, milliseconds etc
If the desired date is really only about the date, you should discard the time component of the parameter to avoid unexpected results, or replace the type with DateOnly
Is TimeRange a class os struct? If it's a class, creating it then discarding the object has a cost that could be greater than checking the condition through something like a subtraction and only creating the TimeRange then.
But also this should be posted in #code-review