Table of Contents

"Now" surfaces — PrimeTime (NodaTime) stack

The PrimeTime (NodaTime) stack adds NodaTime-first "now" projections on IPrimeClock: Instant, ZonedDateTime, LocalTime, and LocalDate — alongside the BCL surfaces from the System Clock subset.

ServiceCollection services = [];
services.AddPrimeClock();

using ServiceProvider serviceProvider = services.BuildServiceProvider();
IPrimeClock primeClock = serviceProvider.GetRequiredService<IPrimeClock>();

ScenarioConsole.WriteLine($"NowInstant: {primeClock.NowInstant}");
ScenarioConsole.WriteLine($"LocalNowInstant: {primeClock.LocalNowInstant}");
ScenarioConsole.WriteLine($"UtcNowInstant: {primeClock.UtcNowInstant}");
ScenarioConsole.WriteLine($"LocalZonedNowInstant: {primeClock.LocalZonedNowInstant}");
ScenarioConsole.WriteLine($"LocalNowTime: {primeClock.LocalNowTime}");
ScenarioConsole.WriteLine($"LocalNowDate: {primeClock.LocalNowDate}");
ScenarioConsole.WriteLine($"LocalNowDateTimeOffset: {primeClock.LocalNowDateTimeOffset:O}");

return Task.CompletedTask;

What to notice

  • NowInstant is the canonical NodaTime UTC instant; it is identical to UtcNowInstant and is the simplest "now" projection.
  • LocalNowInstant is the same instant viewed in the configured local zone; LocalZonedNowInstant returns a full ZonedDateTime that carries zone and offset.
  • LocalNowTime / LocalNowDate return NodaTime LocalTime and LocalDate, useful when scheduling against wall-clock components.
  • BCL projections like LocalNowDateTimeOffset remain available from the shared contract for interop with code that speaks BCL types.