rspec/rules/S6566/pitfalls-dotnet.adoc

7 lines
735 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

=== Pitfalls
Common `DateTime` pitfalls include:
* when working with `DateTime` of kind `Local` consider the time offset of the machine where the program is running. Not storing the offset from UTC separately can result in meaningless data when retrieved from a different location.
* when working with `DateTime` of kind `Unknown`, calling `ToUniversalTime()` presumes the `DateTime.Kind` is local and converts to UTC, if you call the method `ToLocalTime()`, it assumes the `DateTime.Kind` is UTC and converts it to local.
* when comparing `DateTimes` objects, the user must ensure they are within the same time zone. `DateTime` doesnt consider UTC/Local when comparing; it only cares about the number of `Ticks` on the objects.