CleanArchitecture icon indicating copy to clipboard operation
CleanArchitecture copied to clipboard

Replaced DateTimeService with System.TimeProvider

Open tonven opened this issue 1 year ago • 3 comments

Starting from .NET 8 there is an inbuild TimeProvider Class which can be used as an abstractrion over DateTime. https://learn.microsoft.com/en-us/dotnet/api/system.timeprovider?view=net-8.0

tonven avatar Jun 29 '23 09:06 tonven

I think it's better to save in UTC time, and convert to local time for display when outputting.

neozhu avatar Jun 29 '23 10:06 neozhu

I think it's better to save in UTC time, and convert to local time for display when outputting.

I agree. I was also thinking about changing Created and LastModified to DateTimeOffset and saving it to UTC time.

@jasontaylordev what do you think?

tonven avatar Jun 29 '23 11:06 tonven

I think it's better to save in UTC time, and convert to local time for display when outputting.

I agree. I was also thinking about changing Created and LastModified to DateTimeOffset and saving it to UTC time.

@jasontaylordev what do you think?

I agree, thanks for the contribution. 🙂

jasontaylordev avatar Jul 01 '23 01:07 jasontaylordev

Thanks again @tonven. Once the final changes come through, I'll review and merge.

jasontaylordev avatar Jul 05 '23 09:07 jasontaylordev

If you change to using UTC, I suggest to also reflect that to the property names CreatedUTC and LastModifiedUTC

What these values need to contain so depend on the usecase. If these properties are for 'operational' reasons, UTC is the best value, as you can correlate typically with server logs which also (should) have UTC. If these values are to be used to define when the user created/modified the TodoItem, a full DateTimeOffset should be used, unless you are sure to always be operating in a single timezone.

rlarno avatar Jul 05 '23 10:07 rlarno

Closing due to inactivity, feel free to raise again.

jasontaylordev avatar Jul 11 '23 11:07 jasontaylordev