Lyo.DateAndTime 1.0.1

dotnet add package Lyo.DateAndTime --version 1.0.1
                    
NuGet\Install-Package Lyo.DateAndTime -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lyo.DateAndTime" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lyo.DateAndTime" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Lyo.DateAndTime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lyo.DateAndTime --version 1.0.1
                    
#r "nuget: Lyo.DateAndTime, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lyo.DateAndTime@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lyo.DateAndTime&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Lyo.DateAndTime&version=1.0.1
                    
Install as a Cake Tool

Lyo.DateAndTime

Date, time, US timezone conversion, day-of-week scheduling, and US holiday metadata for .NET. The API is static and thread-safe (no mutable shared state).

Target frameworks: netstandard2.0, net10.0

Time zones and DateAndTime

DateAndTime resolves TimeZoneInfo via GeographicInfo.FromState(usState) in Lyo.Common. Each US state maps to an IANA identifier (for example America/New_York, America/Chicago, America/Denver, America/Los_Angeles, America/Phoenix, America/Anchorage, Pacific/Honolulu). If the OS does not recognize the ID, GetTimeZoneByState returns null and conversion helpers return null instead of throwing.

Time zones and DateAndTimeDateAndTime — timezone

Member Description
GetTimeZoneByState(USState) TimeZoneInfo? for the state’s primary mapping, or null.
GetLocalDateTime(USState, DateTime? utc = null) Local DateTime in that zone; utc defaults to DateTime.UtcNow.
GetCurrentLocalDateTime(USState) Same as GetLocalDateTime(state, DateTime.UtcNow).
ConvertToLocalTime(USState, DateTime utcDateTime) Alias of GetLocalDateTime with an explicit UTC instant.
ConvertToUtc(USState, DateTime localDateTime) Interprets localDateTime in the state’s zone and returns UTC, or null if unmapped.

Time zones and DateAndTimeDateAndTime — scheduling

Scheduling uses local DateTime in the given state (GetCurrentLocalDateTime / conversions). DayFlags is a [Flags] enum from Lyo.Common (weekday bits). Internally the day flag is 1 << (int)date.DayOfWeek.

Constants (not configurable): next-slot search looks up to 7 days ahead; discrete-time past-due scans up to 7 days of history when lastRunDateTime is null (default anchor is UTC “now minus 7 days”).

Member Description
GetNextScheduledDateTime(USState, IEnumerable<TimeOnly> times, DayFlags) Next local instant strictly after “now” on an allowed day, for one of the listed clock times.
GetNextScheduledDateTime(USState, TimeOnly start, TimeOnly end, int intervalMinutes, DayFlags) Next instant after “now” on an allowed day, stepping by intervalMinutes within [start, end] inclusive.
IsPastDue(USState, IEnumerable<TimeOnly> times, DayFlags, DateTime? lastRunUtc) true if any scheduled slot after the localized last run and on or before localized “now” falls on an allowed day within the scan window.
IsPastDue(USState, TimeOnly start, TimeOnly end, int minuteInterval, DayFlags, DateTime? lastRunUtc) Window mode: only considers today (local calendar). Returns true only if today is scheduled, “now” is inside [start, end], and the latest tick at or before “now” is after the localized last run.
GetScheduledTimesForDay(DateTime date, IEnumerable<TimeOnly> times, DayFlags) Yields local DateTime values on date.Date for each time if date matches DayFlags. Does not take USState (caller supplies the calendar date).
GetScheduledTimesForDay(DateTime date, TimeOnly start, TimeOnly end, int intervalMinutes, DayFlags) Same, for interval ticks in the window on that calendar date.
IsScheduledDay(DateTime dateTime, DayFlags) Whether dateTime’s day-of-week is included in scheduleFlags.

TimeOnly vs TimeOnlyModel: On net6.0 or greater, scheduling APIs use System.TimeOnly. On netstandard2.0, use Lyo.DateAndTime.TimeOnlyModel, which is source-compatible for typical call sites via conditional compilation in this library (TimeOnly type alias in DateAndTime.cs).


DateOnlyModel and TimeOnlyModel (.NET Standard 2.0)

  • DateOnlyModel — day number from 0001-01-01; Year/Month/Day, Today, AddDays/AddMonths/AddYears, FromDateTime/Parse/TryParse/ParseExact/TryParseExact, comparison operators, ToDateTime(), ToDateTime(TimeOnlyModel).
  • TimeOnlyModel — ticks within one day; constructors from hour/minute/(second)/(ms), Ticks, FromTimeSpan/FromDateTime, parse APIs, ToTimeSpan(), ToDateTime(DateOnlyModel), Add/AddHours/AddMinutes/AddSeconds/AddMilliseconds (wraps within a day).

US holidays — HolidayInfo and HolidayDateRule

HolidayDateRule enum: Unknown, FixedDate, NthWeekdayOfMonth, LastWeekdayOfMonth.

HolidayInfo is an immutable record with: Name, Slug, Description, IsFederal, IsObservedWhenWeekend, DateRule, Month, DayOfMonth, DayOfWeek, Occurrence, Aliases, plus CanonicalName (Slug).

Static instances include (among others): NewYearsDay, MartinLutherKingJrDay, ValentinesDay, PresidentsDay, StPatricksDay, EasterSunday, MothersDay, MemorialDay, Juneteenth, FathersDay, IndependenceDay, LaborDay, ColumbusDay, Halloween, VeteransDay, ThanksgivingDay, ChristmasDay, NewYearsEve, and Unknown.

API Description
HolidayInfo.All All registered holidays (excluding duplicates from reflection order).
HolidayInfo.FederalHolidays Subset with IsFederal.
HolidayInfo.FromName / FromSlug / FromAlias Case-insensitive lookup; blank → Unknown.
GetDate(int year) Calendar date; Easter uses Meeus/Jones/Butcher Gregorian algorithm.
GetObservedDate(int year) If IsObservedWhenWeekend, weekend dates shift to adjacent weekday (Sat → Fri, Sun → Mon).
OccursOn(DateTime date, bool includeObservedDate = true) True if date is the actual or observed holiday date for date.Year.
HolidayInfo.FromDate(DateTime date, bool includeObservedDate = true) First non-Unknown holiday matching that calendar date, or null.

JSON — Lyo.DateAndTime.Json

Type Behavior
DateOnlyModelConverter JsonConverter<DateOnlyModel?> — ISO yyyy-MM-dd strings; null/whitespace → null.
TimeOnlyModelConverter JsonConverter<TimeOnlyModel?>HH:mm:ss.fffffff; null/whitespace → null.
LyoJsonSerializerOptionsExtensions.AddLyoDateOnlyModelConverters(JsonSerializerOptions) Registers both converters and returns options.

Exceptions

Type Typical cause
ArgumentNullException Null collections or required arguments.
ArgumentException Empty schedule lists, invalid intervals (<= 0), startTime > endTime.
InvalidOperationException Unmapped state, or no matching next schedule within the look-ahead window.
FormatException Parse / ParseExact failures on models.
TimeZoneNotFoundException Rare; thrown by BCL if a zone id is invalid in edge environments (library usually returns null from GeographicInfo.TimeZone).

Repository

GitHub Repository

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Common — (direct, lyo)
  • Lyo.Exceptions — (direct, lyo)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 — (transitive, microsoft)
  • System.Memory 4.6.3 — (transitive, microsoft, netstandard2.0)
  • System.Text.Json 10.0.5 — (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Lyo.DateAndTime:

Package Downloads
Lyo.Api.Models

API models and data transfer objects for the Lyo API library suite.

Lyo.Schedule.Models

Shared schedule models for the Lyo library suite. Defines ScheduleDefinition, ScheduleType, and ScheduleDefinitionBuilder used by Lyo.Scheduler, Lyo.Job.Postgres, and other scheduling consumers.

Lyo.Job.Models

Job management models and DTOs for the Lyo API job management system.

Lyo.Scheduler

In-process scheduler service for executing actions at scheduled times. Supports SetTimes, Interval, and OneShot schedules with logging, metrics, and optional state persistence.

Lyo.People.Models

People and person-related models for the Lyo library suite. Includes Person, PersonName, contact info, relationships, employment, identification, and preferences.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 0 8/18/2026
1.0.0 431 8/16/2026