Skip to main content
net8.0.NETStandard2.0

Fix egregiously broken or missing functionality in Noda Time.

Published
May 16, 2026
5mo ago
Total Downloads
10.4K
10,384

Install

dotnet add package Unfucked.DateTime --version 0.0.1-beta.6
ProductVersions
.NET
net8.0
.NET Standard
netstandard2.0

README

🧰 Unfucked.DateTime

NuGet GitHub Actions Testspace Coveralls

Fix egregiously missing functionality in Noda Time. Inspired by Joda-Time.

Unfuck your house

Installation

dotnet package add Unfucked.DateTime
using Unfucked;

Usage

  • Absolute value of a Duration
    ZonedDateTime a, b;
    Duration abs = (a - b).Abs();
    
  • Get midnight from a ZonedDateTime as a ZonedDateTime, Period, or Duration
    ZonedDateTime now = SystemClock.Instance.InTzdbSystemDefaultZone().GetCurrentZonedDateTime();
    ZonedDateTime midnight = now.StartOfDay;
    Duration sinceMidnight = now.LocalDateTime.TimeOfDay.DurationSinceStartOfDay;
    Period sinceMidnight2 = now.LocalDateTime.TimeOfDay.PeriodSinceStartOfDay;
    
  • Convert time zone offset to hours
    double hours = DateTimeZoneProviders.Tzdb["America/Los_Angeles"].GetUtcOffset(SystemClock.Instance.GetCurrentInstant()).Hours;
    
  • Compare two OffsetDateTimes to see which one happens first
    OffsetDateTime a, b;
    bool isBefore = a.IsBefore(b);
    isBefore = !b.IsAfter(a);
    
  • More succinct and interchangeable way to define standard TimeSpan, Period, and Duration instances by force casting integral numbers to or constructing Milliseconds, Seconds, Minutes, Hours, and Days, all of which implicitly convert to TimeSpan, Period, and Duration
    TimeSpan t = (Milliseconds) 3;
    TimeSpan t = (Seconds) 1;
    TimeSpan t = (Minutes) 4;
    Period t   = (Hours) 1;
    Duration t = (Days) 5;
    
  • Convenience accessors to make Noda Time's confusing API more discoverable and understandable. If you somehow really need an alternative instance of IClock to write unit tests, you can do this the original way.
    var clock = DateTimeZoneProviders.Tzdb["America/Los_Angeles"].Clock;
    
    var now = ZonedDateTime.Now;
    var now = ZonedDateTime.NowUtc;
    var now = OffsetDateTime.Now;
    var now = OffsetDateTime.NowUtc;
    var now = Instant.Now;
    var now = LocalDateTime.Now;
    var now = LocalTime.Now;
    var now = LocalDate.Now;
    
  • Automatically periodically update the IANA time zone database (tzdb) that is included with Noda Time by fetching it from Noda Time's servers. This allows your program to get time zone updates without having to update a NuGet package, recompile, deploy a new version, or restart your process.
    IDateTimeZoneProvider tzdb = DateTimeZoneProviders.CreateOnlineUpdatingTzdbProvider(TimeSpan.FromDays(1));
    ZonedDateTime now = tzdb["America/Los_Angeles"].Clock.GetCurrentZonedDateTime();
    

All Unfucked libraries

Changes from Previous Version

v0.0.1-beta.5v0.0.1-beta.6
Added Frameworks
net8.0
Added Dependencies
NodaTime(net8.0)

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.