Unfucked.DateTime
v0.0.1-beta.6Latest Pre-release
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
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard |
README
🧰 Unfucked.DateTime
Fix egregiously missing functionality in Noda Time. Inspired by Joda-Time.
Installation
dotnet package add Unfucked.DateTime
using Unfucked;
Usage
- Absolute value of a
DurationZonedDateTime a, b; Duration abs = (a - b).Abs(); - Get midnight from a
ZonedDateTimeas aZonedDateTime,Period, orDurationZonedDateTime 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
OffsetDateTimesto see which one happens firstOffsetDateTime a, b; bool isBefore = a.IsBefore(b); isBefore = !b.IsAfter(a); - More succinct and interchangeable way to define standard
TimeSpan,Period, andDurationinstances by force casting integral numbers to or constructingMilliseconds,Seconds,Minutes,Hours, andDays, all of which implicitly convert toTimeSpan,Period, andDurationTimeSpan 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
IClockto 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
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.
