Table of Contents

Method ToTimeSpanForTimerInterval

Namespace
KZDev.PrimeTime
Assembly
KZDev.PrimeTime.dll

ToTimeSpanForTimerInterval(Duration)

Converts a NodaTime.Duration to TimeSpan for interval timer registration, timer Change operations, and virtual clock deltas so behavior matches IPrimeClock TimeSpan-based timer registration overloads.

public static TimeSpan ToTimeSpanForTimerInterval(Duration duration)

Parameters

duration Duration

The duration to convert (initial delay, repeat interval, or virtual time delta).

Returns

TimeSpan

MaxValue when duration is strictly positive and does not fit in a TimeSpan; otherwise the result of NodaTime.Duration.ToTimeSpan().

Remarks

Unlike ToTimeSpanForDelay(Duration) and ToTimeSpanForCancellationToken(Duration), zero and negative durations are not mapped to Zero; they use NodaTime.Duration.ToTimeSpan() so Noda NodaTime.Duration overloads stay aligned with BCL TimeSpan values passed into shared timer and virtual-time registration (including non-positive and sentinel spans such as InfiniteTimeSpan).

Exceptions

OverflowException

Thrown by NodaTime.Duration.ToTimeSpan() when duration is not representable as a TimeSpan.