Time conversion issue?
What am I missing here? The date, start and end are in local. For some reason this is returning true even though if the current start and end are in the past? I have written some tests, all of them are passing locally. When testing from the client, the behavior is not the same. The client is calling the server.
6 Replies
i recommend not using datetime, use datetimeoffset at least because that actually stores offset information
there is probably an issue with differences in the time set on the different machines
I can try that out and see.
Should I have stored the start and end as DateTimeOffset instead of TimeOnly?
I thought this would be enough.
it depends, do you need to account for time zone changes when handling them?
Not really, the problem is that sometimes I need to make sure that details are in future. The thing is that I don't want to store the start and end as utc or the date. It's leading to some issues when creating stuff or querying. During validation, I need to absolutely make sure that stuff are not in the past.
Maybe I should remove date and just have start and end as DateTimeOffset. Since sometimes you can have an overnight shift.
unless shifts can be longer than 24 hours timeonly would probably be fine?
No, the shifts cannot be longer then 24 hours.
Ok. thank you very much for the input. I will look into some more options and decide.