Slide 1

Slide 1 text

Why you should use DateTimeOffset

Slide 2

Slide 2 text

Don’t use DateTime Use DateTimeOffset

Slide 3

Slide 3 text

DateTime vs. DateTimeOffset ▪ DateTimeOffset was introduced very early with .NET 2.0 to correct design flaws of DateTime from .NET 1.0. ▪ Unlike DateTime, DateTimeOffset represents a truly instantaneous time, also known as absolute time. ▪ The use of DateTime often results in the loss of uniqueness of the exact date and time → uncorrectable consequential issues. ▪ DateTimeOffset values are much more common than those for DateTime values. As a result, DateTimeOffset should be the default date and time type in all you .NET Apps and Libs. https://docs.microsoft.com/en-us/dotnet/standard/datetime/choosing-between-datetime

Slide 4

Slide 4 text

https://docs.microsoft.com/en-us/dotnet/standard/datetime/choosing-between-datetime Stop using DateTime, wherever possible! Use DateTimeOffset

Slide 5

Slide 5 text

Respect ISO 8601 ISO 8601 represents an international standard and covers all date- and time related information. Use Extension Methods for easier and general access.

Slide 6

Slide 6 text

New .NET 6 Types DateOnly and TimeOnly ▪ Long-awaited Types will be part of .NET 6 (starting preview 4) ▪ They only represent a date or a time without any time zone relation ▪ Work well with existing implementations like in databases ▪ Use them for stuff like recurring jobs, alarms (e.g., every morning 08:00), use cases where you don’t need absolute time DON’T USE THEM FOR ABSOLUTE TIME INFORMATION

Slide 7

Slide 7 text

No content