PrimeTime (NodaTime) examples
Self-contained snippets for the KZDev.PrimeTime stack, the NodaTime superset that ships Instant, Duration, LocalTime, LocalDate, and ZonedDateTime APIs on top of the BCL surfaces. Each page shows code copied directly from the in-repo example projects:
- Production demos live in
Source/Dev/Production/KZDev.PrimeTime.Examples/. - Test demos live in
Source/Dev/Testing/KZDev.PrimeTime.Testing.Examples/and use xUnit with AwesomeAssertions.
Production
- Interval timers — register sync and async interval callbacks on
IPrimeClockusing NodaTimeDuration. - Time-of-day and DST — register local
LocalTimecallbacks, plus environment-aware skipped/ambiguous handling and the clock'sLocalScheduleTimeZone. - DI registration — what
AddPrimeClockregisters and how to resolve the abstractions, including the NodaTimeIClock. - "Now" surfaces — the NodaTime-first projections (
NowInstant,LocalZonedNowInstant,LocalNowTime,LocalNowDate, etc.). - Persistence and conversions (production) — project persisted
Instantvalues into the schedule zone;LocalTimeOfDayround-trip; delayTimeSpanclamping. - Sleep, delay, and cancellation —
Sleep,DelayAsync, and time-based cancellation tokens, all expressed withDuration.
Testing (virtual time)
- Interval timers (testing) — drive interval timers under
PrimeTestClockwithAdvance. - Time-of-day and DST (testing) — deterministic spring-forward and fall-back examples against a fixed
DateTimeZone. - Persistence and conversions (testing) — schedule-zone projections and duration clamping under
PrimeTestClock.
Cross-track testing examples
The following pages cover patterns shared by both stacks; both are presented side-by-side:
Related
- Concepts: Persistence and time conversions · Timers, daylight saving, and testing
- Usage guide: KZDev.PrimeTime
- API: Production · Testing