System.DateTime is a frustrating object for a number of reasons, many of
which I hope to elaborate in future posts.
Imagine you have a class, that for correctness, requires a
to be in UTC. How can you communicate and enforce this fact to users of your
Unfortunately, there is nothing like a
UtcDateTime class in the .NET BCL. You’re basically
stuck with the following:
1 2 3 4 5 6 7 8 9 10
There are only two signals to future programmers:
- the “Utc” suffix on your parameter name
You have absolutely no way to enforce at compile time that someone actually passed you the UTC time you need. Relying on exceptions and parameter names is confusing and error prone.