Class ZonedClockExtensions
- Namespace
- LfrlAnvil.Chrono.Extensions
- Assembly
- LfrlAnvil.Chrono.dll
Contains IZonedClock extension methods.
public static class ZonedClockExtensions
- Inheritance
-
ZonedClockExtensions
- Inherited Members
Methods
Create(IZonedClock, DateTime)
Creates a new ZonedDateTime instance from the provided dateTime
and with the time zone of the given clock.
[Pure]
public static ZonedDateTime Create(this IZonedClock clock, DateTime dateTime)
Parameters
clockIZonedClockSource clock.
dateTimeDateTimeDate time value.
Returns
- ZonedDateTime
New ZonedDateTime instance.
Exceptions
- InvalidZonedDateTimeException
When
dateTimeis not a valid date time in the clock's time zone.
Freeze(IZonedClock)
Creates a new frozen IZonedClock instance from the given clock,
using its current ZonedDateTime.
[Pure]
public static IZonedClock Freeze(this IZonedClock clock)
Parameters
clockIZonedClockSource clock.
Returns
- IZonedClock
New frozen IZonedClock instance.
GetDurationOffset(IZonedClock, IZonedClock)
Calculates an offset between current ZonedDateTime instances of two clocks.
[Pure]
public static Duration GetDurationOffset(this IZonedClock clock, IZonedClock other)
Parameters
clockIZonedClockSource clock.
otherIZonedClockOther clock to check.
Returns
GetDurationOffset(IZonedClock, ZonedDateTime)
Calculates an offset between the provided dateTime
and the current ZonedDateTime of the given clock.
[Pure]
public static Duration GetDurationOffset(this IZonedClock clock, ZonedDateTime dateTime)
Parameters
clockIZonedClockSource clock.
dateTimeZonedDateTimeDate time to check.
Returns
IsFrozen(IZonedClock)
Checks whether or not the given clock is frozen.
[Pure]
public static bool IsFrozen(this IZonedClock clock)
Parameters
clockIZonedClockClock to check.
Returns
- bool
true when
clockis frozen, otherwise false.
IsInFuture(IZonedClock, ZonedDateTime)
Checks whether or not the provided dateTime is in the future
relative to the given clock.
[Pure]
public static bool IsInFuture(this IZonedClock clock, ZonedDateTime dateTime)
Parameters
clockIZonedClockSource clock.
dateTimeZonedDateTimeDate time to check.
Returns
- bool
true when
dateTimeis in the future, otherwise false.
IsInPast(IZonedClock, ZonedDateTime)
Checks whether or not the provided dateTime is in the past
relative to the given clock.
[Pure]
public static bool IsInPast(this IZonedClock clock, ZonedDateTime dateTime)
Parameters
clockIZonedClockSource clock.
dateTimeZonedDateTimeDate time to check.
Returns
- bool
true when
dateTimeis in the past, otherwise false.
IsNow(IZonedClock, ZonedDateTime)
Checks whether or not the provided dateTime is in the present
relative to the given clock.
[Pure]
public static bool IsNow(this IZonedClock clock, ZonedDateTime dateTime)
Parameters
clockIZonedClockSource clock.
dateTimeZonedDateTimeDate time to check.
Returns
- bool
true when
dateTimeis in the present, otherwise false.
TryCreate(IZonedClock, DateTime)
Attempts to create a new ZonedDateTime instance from the provided dateTime
and with the time zone of the given clock.
[Pure]
public static ZonedDateTime? TryCreate(this IZonedClock clock, DateTime dateTime)
Parameters
clockIZonedClockSource clock.
dateTimeDateTimeDate time value.
Returns
- ZonedDateTime?
New ZonedDateTime instance or null when
dateTimeis not a valid date time in the clock's time zone.