Working with Date and Time

Date and time values are notoriously hard to work with for a variety of reasons, most of which have to do with globalization. Different calendar systems exist, people live in different time zones, representation of dates can be done in a number of ways, and so on. The designers of the .NET Framework tried hard to accommodate all those needs using just a handful of types. And quite frankly, they did quite a good job of it, with only one introduction of a new type in .NET 2.0 to compensate for the lack of a good solution to time offsets relative to universal coordinated time (UTC) time.

Absolute Time and DateTime

The first notion we need is that of absolute time. DateTime is the struct that’s used to represent such values, ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.