Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class NodaTime.​Extensions.​TimeProviderExtensions

Assembly: NodaTime

Inheritance: object → TimeProviderExtensions

Extension methods for <see cref="T:System.TimeProvider" /> .

Methods

public static IClock
ToClock​(System.​TimeProvider timeProvider)
Returns an <see cref="T:NodaTime.IClock" /> implementation which delegates to <paramref name="timeProvider" /> to obtain the current instant in time.
Returns An <see cref="T:NodaTime.IClock" /> implementation based on the given time provider.
timeProvider The time provider to obtain the current instant in time from. Must not be null.
public static Instant
GetCurrentInstant​(System.​TimeProvider timeProvider)
Returns the current instant in time provided by <paramref name="timeProvider" /> , as an <see cref="T:NodaTime.Instant" /> .
Returns The current instant in time as returned by the given time provider, expressed as an <see cref="T:NodaTime.Instant" /> .
timeProvider The time provider to obtain the current instant in time from. Must not be null.
Remarks This is equivalent to calling <see cref="M:System.TimeProvider.GetUtcNow" /> , and then calling <see cref="M:NodaTime.Extensions.DateTimeOffsetExtensions.ToInstant(System.DateTimeOffset)" /> on the result.
public static ZonedClock
ToZonedClock​(System.​TimeProvider timeProvider)
Returns a <see cref="T:NodaTime.ZonedClock" /> which obtains the current instant in time and the local time zone from <paramref name="timeProvider" /> , and uses the ISO calendar.
Returns A <see cref="T:NodaTime.ZonedClock" /> backed by the given time provider.
timeProvider The time provider to delegate to. Must not be null.
Remarks The local time zone is captured from the time provider at the time of this call. If the time provider changes which time zone is reported by <see cref="P:System.TimeProvider.LocalTimeZone" /> after this call has returned, that change will not be reflected in the returned <see cref="T:NodaTime.ZonedClock" /> .
public static ZonedClock
ToZonedClock​(System.​TimeProvider timeProvider, CalendarSystem calendar)
Returns a <see cref="T:NodaTime.ZonedClock" /> which obtains the current instant in time and the local time zone from <paramref name="timeProvider" /> , and uses the provided calendar system.
Returns A <see cref="T:NodaTime.ZonedClock" /> backed by the given time provider.
timeProvider The time provider to delegate to. Must not be null.
calendar The calendar system to use in the returned <see cref="T:NodaTime.ZonedClock" /> . Must not be null.
Remarks The local time zone is captured from the time provider at the time of this call. If the time provider changes which time zone is reported by <see cref="P:System.TimeProvider.LocalTimeZone" /> after this call has returned, that change will not be reflected in the returned <see cref="T:NodaTime.ZonedClock" /> .
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object