3 ms·
They should have gone further like .NET 8.0 with a full class abstraction for datetime provider: https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-
by Belphemur 3y ago
They should have gone further like .NET 8.0 with a full class abstraction for datetime provider:
https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8#time-abstraction https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotn...
This is 10x better and helps to assure the code can be unit tested with providing the exact date we want in the exact format/timezone
- lallysingh 3y agoThat's a lot of complexity. How's that better than requiring an arg with the timezone?
- rjbwork 3y agoBecause you can now fully simulate arbitrary times during testing by providing your own implementation of the time provider. If you just take in a timezone as an argument, how will you simulate it being 2041-08-23T21:17:05.023743Z?
- SpaghettiCthulu 3y agoUh, just assign your mock function to `<insert name here>`? Python is really the wrong language to be complaining about a lack of mockability.
- rjbwork 3y agoTrue. When you can just make any function be whatever you want whenever you want that sort of abstraction does seem a big much. I was responding to the specific question in reference to the time provider in .net 8.
- SpaghettiCthulu 3y agoAh, fair enough. C# certainly presents more of a need for that sort of abstraction, being a statically typed language.