Portable Class Library Support for Noda Time
Noda time divides its type system into two categories: local and global.
Local types are not bound to any time zone, but may include a calendar component. This is similar to the DateTime class with the DateTimeKind set to unspecified. However, Noda Time also supports time only and date only values.
Global types are based on the concept of the Instant. An Instant is a specific moment in the universal timeline. For compatibility with other systems, it is based on ticks since January 1st 1970, UTC (the Unix epoch). There are 10,000 ticks per millisecond, allowing for fairly high resolutions. Though it should be noted that some scientific instruments can measure time in ticks that are as small as 10-18 seconds.
Some classes such as ZonedDateTime will combine an Instant with time-zone information. Unlike DateTimeOffset, a ZonedDateTime contains the actual timezone information that needs to be presented to the user.
This conversion chart from the documentation shows how the core types are related:
Another advantage of Noda Time over the BCL is support for historical dates. The BCL’s DateTime class has a min value of year 1 CE. Noda Time supports approximately 27000 BCE, allowing it to be used in applications that need to compare timelines between ancient Egypt and China.
Noda Time supports both the Windows and the Olson time zone databases. Since governments frequently change their time zone laws, Noda Time allows you to inject a more recent version of the database.
In Noda Time, Period and Duration mean different things. A Duration is a fixed amount of time that can be measured in ticks. A Period is an abstract concept such as “one month” or “two weeks”. “The amount of elapsed time represented by a Period isn't fixed: a period of "one month" is effectively longer when added to January 1st than when added to February 1st, because February is always shorter than January.”
Based on Java’s Joda Time, Noda Time was designed to correct many of the problems in the existing .NET date/time classes. For example, it allows developers to directly represent a date without a time component, eliminating the problem of accidentally changing “Midnight, Dec 10” into “11 pm, Dec 9” due to an unnecessary time zone conversion.
To support testing, Noda Time offers an IClock interface. This is implemented by SystemClock and FakeClock, Once initialized, FakeClock can be manually incremented or set to auto-increment itself by a fixed amount.
Noda Time is offered under the Apache License.
Srini Penchikala Aug 21, 2014