Class ZonedClock
A clock with an associated time zone and calendar. This is effectively a convenience
class decorating an IClock.
Implements
Inherited Members
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Declaration
public ZonedDateTime GetCurrentZonedDateTime()
Returns
Type | Description |
---|---|
ZonedDateTime | The current instant provided by the underlying clock, adjusted to the time zone of this object. |