Table of Contents

Struct ZonedDay

Namespace
LfrlAnvil.Chrono
Assembly
LfrlAnvil.Chrono.dll

Represents a day with time zone.

public readonly struct ZonedDay : IEquatable<ZonedDay>, IComparable<ZonedDay>, IComparable
Implements
Inherited Members

Properties

DayOfMonth

Day of month component.

public int DayOfMonth { get; }

Property Value

int

DayOfWeek

Day of week component.

public IsoDayOfWeek DayOfWeek { get; }

Property Value

IsoDayOfWeek

DayOfYear

Day of year component.

public int DayOfYear { get; }

Property Value

int

Duration

Duration of this day.

public Duration Duration { get; }

Property Value

Duration

End

End of this day.

public ZonedDateTime End { get; }

Property Value

ZonedDateTime

IsLocal

Checks whether or not the TimeZone is local.

public bool IsLocal { get; }

Property Value

bool

IsUtc

Checks whether or not the TimeZone is UTC.

public bool IsUtc { get; }

Property Value

bool

Month

Month component.

public IsoMonthOfYear Month { get; }

Property Value

IsoMonthOfYear

Start

Start of this day.

public ZonedDateTime Start { get; }

Property Value

ZonedDateTime

TimeZone

Time zone of this day.

public TimeZoneInfo TimeZone { get; }

Property Value

TimeZoneInfo

Year

Year component.

public int Year { get; }

Property Value

int

Methods

Add(Period)

Creates a new ZonedDay instance by adding value to this instance.

[Pure]
public ZonedDay Add(Period value)

Parameters

value Period

Period to add.

Returns

ZonedDay

New ZonedDay instance.

AddDays(int)

Creates a new ZonedDay instance by adding provided number of days to this instance.

[Pure]
public ZonedDay AddDays(int days)

Parameters

days int

Number of days to add.

Returns

ZonedDay

New ZonedDay instance.

CompareTo(ZonedDay)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

[Pure]
public int CompareTo(ZonedDay other)

Parameters

other ZonedDay

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

CompareTo(object?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

[Pure]
public int CompareTo(object? obj)

Parameters

obj object

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes obj in the sort order.
Zero This instance occurs in the same position in the sort order as obj.
Greater than zero This instance follows obj in the sort order.

Exceptions

ArgumentException

obj is not the same type as this instance.

Contains(ZonedDateTime)

Checks whether or not the provided dateTime belongs to this day.

[Pure]
public bool Contains(ZonedDateTime dateTime)

Parameters

dateTime ZonedDateTime

Date time to check.

Returns

bool

true when the provided dateTime belongs to this day, otherwise false.

Create(ZonedDateTime)

Creates a new ZonedDay instance.

[Pure]
public static ZonedDay Create(ZonedDateTime dateTime)

Parameters

dateTime ZonedDateTime

Date time contained by the result.

Returns

ZonedDay

New ZonedDay instance.

Create(DateTime, TimeZoneInfo)

Creates a new ZonedDay instance.

[Pure]
public static ZonedDay Create(DateTime dateTime, TimeZoneInfo timeZone)

Parameters

dateTime DateTime

Date time contained by the result.

timeZone TimeZoneInfo

Target time zone.

Returns

ZonedDay

New ZonedDay instance.

CreateLocal(DateTime)

Creates a new ZonedDay instance in Local time zone.

[Pure]
public static ZonedDay CreateLocal(DateTime localDateTime)

Parameters

localDateTime DateTime

Date time contained by the result.

Returns

ZonedDay

New ZonedDay instance.

CreateUtc(Timestamp)

Creates a new ZonedDay instance in Utc time zone.

[Pure]
public static ZonedDay CreateUtc(Timestamp timestamp)

Parameters

timestamp Timestamp

Timestamp contained by the result.

Returns

ZonedDay

New ZonedDay instance.

CreateUtc(DateTime)

Creates a new ZonedDay instance in Utc time zone.

[Pure]
public static ZonedDay CreateUtc(DateTime utcDateTime)

Parameters

utcDateTime DateTime

Date time contained by the result.

Returns

ZonedDay

New ZonedDay instance.

Equals(ZonedDay)

Indicates whether the current object is equal to another object of the same type.

[Pure]
public bool Equals(ZonedDay other)

Parameters

other ZonedDay

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

[Pure]
public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetDateTime(TimeOfDay)

Creates a new ZonedDateTime instance by setting the TimeOfDay component in this instance's Start date time.

[Pure]
public ZonedDateTime GetDateTime(TimeOfDay timeOfDay)

Parameters

timeOfDay TimeOfDay

Time of day to set.

Returns

ZonedDateTime

New ZonedDateTime instance.

Exceptions

InvalidZonedDateTimeException

When result is not valid in this instance's TimeZone.

GetGreedyPeriodOffset(ZonedDay, PeriodUnits)

Creates a new Period instance by calculating a difference between this instance and the start instance, where this instance is treated as the end of the range, using the specified units.

[Pure]
public Period GetGreedyPeriodOffset(ZonedDay start, PeriodUnits units)

Parameters

start ZonedDay

Start day.

units PeriodUnits

PeriodUnits to include in the calculated difference.

Returns

Period

New Period instance.

Remarks

Greedy Period may contain components with negative values.

GetHashCode()

Returns the hash code for this instance.

[Pure]
public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetIntersectingAmbiguityRange()

Attempts to find the range of ambiguous date times in this instance, according to its TimeZone.

[Pure]
public Bounds<DateTime>? GetIntersectingAmbiguityRange()

Returns

Bounds<DateTime>?

New Bounds<T> instance that represents the range of ambiguous date times or null when this instance does not contain invalid date times.

GetIntersectingInvalidityRange()

Attempts to find the range of invalid date times in this instance, according to its TimeZone.

[Pure]
public Bounds<DateTime>? GetIntersectingInvalidityRange()

Returns

Bounds<DateTime>?

New Bounds<T> instance that represents the range of invalid date times or null when this instance does not contain invalid date times.

GetMonth()

Creates a new ZonedMonth instance that contains this instance.

[Pure]
public ZonedMonth GetMonth()

Returns

ZonedMonth

New ZonedMonth instance.

GetNext()

Creates a new ZonedDay instance by calculating the next day.

[Pure]
public ZonedDay GetNext()

Returns

ZonedDay

New ZonedDay instance.

GetPeriodOffset(ZonedDay, PeriodUnits)

Creates a new Period instance by calculating a difference between this instance and the start instance, where this instance is treated as the end of the range, using the specified units.

[Pure]
public Period GetPeriodOffset(ZonedDay start, PeriodUnits units)

Parameters

start ZonedDay

Start day.

units PeriodUnits

PeriodUnits to include in the calculated difference.

Returns

Period

New Period instance.

GetPrevious()

Creates a new ZonedDay instance by calculating the previous day.

[Pure]
public ZonedDay GetPrevious()

Returns

ZonedDay

New ZonedDay instance.

GetWeek(IsoDayOfWeek)

Creates a new ZonedWeek instance that contains this instance.

[Pure]
public ZonedWeek GetWeek(IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

weekStart IsoDayOfWeek

First day of the week.

Returns

ZonedWeek

New ZonedWeek instance.

GetYear()

Creates a new ZonedYear instance that contains this instance.

[Pure]
public ZonedYear GetYear()

Returns

ZonedYear

New ZonedYear instance.

SetDayOfMonth(int)

Creates a new ZonedDay instance by setting the DayOfMonth component in this instance.

[Pure]
public ZonedDay SetDayOfMonth(int day)

Parameters

day int

Day of month to set.

Returns

ZonedDay

New ZonedDay instance.

Exceptions

ArgumentOutOfRangeException

When day is not valid for the current month.

SetDayOfYear(int)

Creates a new ZonedDay instance by setting the DayOfYear component in this instance.

[Pure]
public ZonedDay SetDayOfYear(int day)

Parameters

day int

Day of year to set.

Returns

ZonedDay

New ZonedDay instance.

Exceptions

ArgumentOutOfRangeException

When day is not valid for the current year.

SetMonth(IsoMonthOfYear)

Creates a new ZonedDay instance by setting the Month component in this instance.

[Pure]
public ZonedDay SetMonth(IsoMonthOfYear month)

Parameters

month IsoMonthOfYear

Month to set.

Returns

ZonedDay

New ZonedDay instance.

Remarks

Result may end up with modified components other than the month, if it lands in the range of invalid values of this instance's TimeZone.

SetYear(int)

Creates a new ZonedDay instance by setting the Year component in this instance.

[Pure]
public ZonedDay SetYear(int year)

Parameters

year int

Year to set.

Returns

ZonedDay

New ZonedDay instance.

Remarks

Result may end up with modified components other than the year, if it lands in the range of invalid values of this instance's TimeZone.

Exceptions

ArgumentOutOfRangeException

When year is not valid.

Subtract(Period)

Creates a new ZonedDay instance by subtracting value from this instance.

[Pure]
public ZonedDay Subtract(Period value)

Parameters

value Period

Period to subtract.

Returns

ZonedDay

New ZonedDay instance.

SubtractDays(int)

Creates a new ZonedDay instance by subtracting provided number of days from this instance.

[Pure]
public ZonedDay SubtractDays(int days)

Parameters

days int

Number of days to subtract.

Returns

ZonedDay

New ZonedDay instance.

ToBounds()

Creates a new Bounds<T> instance from this instance's Start and End.

[Pure]
public Bounds<ZonedDateTime> ToBounds()

Returns

Bounds<ZonedDateTime>

New Bounds<T> instance.

ToCheckedBounds()

Creates a new BoundsRange<T> instance from this instance's Start and End including any overlapping ambiguity.

[Pure]
public BoundsRange<ZonedDateTime> ToCheckedBounds()

Returns

BoundsRange<ZonedDateTime>

New BoundsRange<T> instance.

ToLocalTimeZone()

Creates a new ZonedDay in Local time zone from this instance.

[Pure]
public ZonedDay ToLocalTimeZone()

Returns

ZonedDay

New ZonedDay instance.

ToString()

Returns a string representation of this ZonedDay instance.

[Pure]
public override string ToString()

Returns

string

String representation.

ToTimeZone(TimeZoneInfo)

Creates a new ZonedDay in the targetTimeZone from this instance.

[Pure]
public ZonedDay ToTimeZone(TimeZoneInfo targetTimeZone)

Parameters

targetTimeZone TimeZoneInfo

Target time zone.

Returns

ZonedDay

New ZonedDay instance.

ToUtcTimeZone()

Creates a new ZonedDay in Utc time zone from this instance.

[Pure]
public ZonedDay ToUtcTimeZone()

Returns

ZonedDay

New ZonedDay instance.

TryGetDateTime(TimeOfDay)

Attempts to create a new ZonedDateTime instance by setting the TimeOfDay component in this instance's Start date time.

[Pure]
public ZonedDateTime? TryGetDateTime(TimeOfDay timeOfDay)

Parameters

timeOfDay TimeOfDay

Time of day to set.

Returns

ZonedDateTime?

New ZonedDateTime instance or null when result is not valid in this instance's TimeZone.

Operators

operator +(ZonedDay, Period)

Creates a new ZonedDay instance by adding a and b together.

[Pure]
public static ZonedDay operator +(ZonedDay a, Period b)

Parameters

a ZonedDay

First operand.

b Period

Second operand.

Returns

ZonedDay

New ZonedDay instance.

operator ==(ZonedDay, ZonedDay)

Checks if a is equal to b.

[Pure]
public static bool operator ==(ZonedDay a, ZonedDay b)

Parameters

a ZonedDay

First operand.

b ZonedDay

Second operand.

Returns

bool

true when operands are equal, otherwise false.

explicit operator ZonedDateTime(ZonedDay)

Converts the provided source to ZonedDateTime.

[Pure]
public static explicit operator ZonedDateTime(ZonedDay source)

Parameters

source ZonedDay

Value to convert.

Returns

ZonedDateTime

Start.

explicit operator DateTime(ZonedDay)

Converts the provided source to DateTime.

[Pure]
public static explicit operator DateTime(ZonedDay source)

Parameters

source ZonedDay

Value to convert.

Returns

DateTime

Value of Start.

operator >(ZonedDay, ZonedDay)

Checks if a is greater than b.

[Pure]
public static bool operator >(ZonedDay a, ZonedDay b)

Parameters

a ZonedDay

First operand.

b ZonedDay

Second operand.

Returns

bool

true when a is greater than b, otherwise false.

operator >=(ZonedDay, ZonedDay)

Checks if a is greater than or equal to b.

[Pure]
public static bool operator >=(ZonedDay a, ZonedDay b)

Parameters

a ZonedDay

First operand.

b ZonedDay

Second operand.

Returns

bool

true when a is greater than or equal to b, otherwise false.

operator !=(ZonedDay, ZonedDay)

Checks if a is not equal to b.

[Pure]
public static bool operator !=(ZonedDay a, ZonedDay b)

Parameters

a ZonedDay

First operand.

b ZonedDay

Second operand.

Returns

bool

true when operands are not equal, otherwise false.

operator <(ZonedDay, ZonedDay)

Checks if a is less than b.

[Pure]
public static bool operator <(ZonedDay a, ZonedDay b)

Parameters

a ZonedDay

First operand.

b ZonedDay

Second operand.

Returns

bool

true when a is less than b, otherwise false.

operator <=(ZonedDay, ZonedDay)

Checks if a is less than or equal to b.

[Pure]
public static bool operator <=(ZonedDay a, ZonedDay b)

Parameters

a ZonedDay

First operand.

b ZonedDay

Second operand.

Returns

bool

true when a is less than or equal to b, otherwise false.

operator -(ZonedDay, Period)

Creates a new ZonedDay instance by subtracting b from a.

[Pure]
public static ZonedDay operator -(ZonedDay a, Period b)

Parameters

a ZonedDay

First operand.

b Period

Second operand.

Returns

ZonedDay

New ZonedDay instance.