Im having an issue checking for collisions when comparing DateTime objects.
I have this function that's supposed to check for collisions with bookings. I am using TimeSpans and DateTime objects. I found a post on Stackoverflow that this...
When using this code during normal time periods from 12am to 11pm it works perfectly fine but when I do a check for a time thats supposed to go into a new day it doesnt take that into account.
Im not sure what else I could add to this function to take that into account.
For example if i have a booking that's at 11:30:00pm and the timespan is for an hour, it should in theory be booked until 12:30:00am. But for some reason when I submit a booking for 12am it returns true.
4 Replies
I added a Library now called TimePeriodLibrary.NET, it doesnt help either. Same issue. Does anyone have any ideas?
All the stuff with CollectionsMarshal and Unsafe is completely unnecessary. Just loop through your list
The rest looks fine though. There's nothing in that code which cares about what day it is
The problem is, I need to take the day into account. I want to make sure that there is a collision when there is an overlap
Do you know a way I can do that?
I need to make sure that there is a collision error on the situation i specified in the post when it returns true. it should be false because its an overlap.
I managed to fix it, it wasnt the comparison after all. It was me looping through an empty array. I wasnt fetching the correct bookings lol
I think canton7 was mentioning that you're basically getting unsafe references for no reason. you're whole thing can basically be
or if you still want to loop