Noda Time
Show / Hide Table of Contents

Class ZonedClock

A clock with an associated time zone and calendar. This is effectively a convenience class decorating an IClock.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Inheritance
object
ZonedClock
Implements
IClock
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
public sealed class ZonedClock : IClock

Constructors

ZonedClock(IClock, DateTimeZone, CalendarSystem)

Creates a new ZonedClock with the given clock, time zone and calendar system.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public ZonedClock(IClock clock, DateTimeZone zone, CalendarSystem calendar)
Parameters
Type Name Description
IClock clock Clock to use to obtain instants.
DateTimeZone zone Time zone to adjust instants into.
CalendarSystem calendar Calendar system to use.

Properties

Calendar

Gets the calendar system used when converting the current instant into a calendar-sensitive value.
Since 3.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public CalendarSystem Calendar { get; }
Property Value
Type Description
CalendarSystem The calendar system associated with this zoned clock.

Clock

Gets the clock used to provide the current instant.
Since 3.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public IClock Clock { get; }
Property Value
Type Description
IClock The clock associated with this zoned clock.

Zone

Gets the time zone used when converting the current instant into a zone-sensitive value.
Since 3.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public DateTimeZone Zone { get; }
Property Value
Type Description
DateTimeZone The time zone associated with this zoned clock.

Methods

GetCurrentDate()

Returns the local date of the current instant provided by the underlying clock, adjusted to the time zone of this object.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public LocalDate GetCurrentDate()
Returns
Type Description
LocalDate The local date of the current instant provided by the underlying clock, adjusted to the time zone of this object.

GetCurrentInstant()

Returns the current instant provided by the underlying clock.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public Instant GetCurrentInstant()
Returns
Type Description
Instant The current instant provided by the underlying clock.

GetCurrentLocalDateTime()

Returns the local date/time of the current instant provided by the underlying clock, adjusted to the time zone of this object.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public LocalDateTime GetCurrentLocalDateTime()
Returns
Type Description
LocalDateTime The local date/time of the current instant provided by the underlying clock, adjusted to the time zone of this object.

GetCurrentOffsetDateTime()

Returns the offset date/time of the current instant provided by the underlying clock, adjusted to the time zone of this object.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public OffsetDateTime GetCurrentOffsetDateTime()
Returns
Type Description
OffsetDateTime The offset date/time of the current instant provided by the underlying clock, adjusted to the time zone of this object.

GetCurrentTimeOfDay()

Returns the local time of the current instant provided by the underlying clock, adjusted to the time zone of this object.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public LocalTime GetCurrentTimeOfDay()
Returns
Type Description
LocalTime The local time of the current instant provided by the underlying clock, adjusted to the time zone of this object.

GetCurrentZonedDateTime()

Returns the current instant provided by the underlying clock, adjusted to the time zone of this object.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public ZonedDateTime GetCurrentZonedDateTime()
Returns
Type Description
ZonedDateTime The current instant provided by the underlying clock, adjusted to the time zone of this object.

Implements

IClock

Extension Methods

ClockExtensions.InBclSystemDefaultZone(IClock)
ClockExtensions.InTzdbSystemDefaultZone(IClock)
ClockExtensions.InUtc(IClock)
ClockExtensions.InZone(IClock, DateTimeZone)
ClockExtensions.InZone(IClock, DateTimeZone, CalendarSystem)
In this article
Back to top Generated by DocFX