Struct ZonedDay
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
DayOfWeek
Day of week component.
public IsoDayOfWeek DayOfWeek { get; }
Property Value
DayOfYear
Day of year component.
public int DayOfYear { get; }
Property Value
Duration
Duration of this day.
public Duration Duration { get; }
Property Value
End
End of this day.
public ZonedDateTime End { get; }
Property Value
IsLocal
Checks whether or not the TimeZone is local.
public bool IsLocal { get; }
Property Value
IsUtc
Checks whether or not the TimeZone is UTC.
public bool IsUtc { get; }
Property Value
Month
Month component.
public IsoMonthOfYear Month { get; }
Property Value
Start
Start of this day.
public ZonedDateTime Start { get; }
Property Value
TimeZone
Time zone of this day.
public TimeZoneInfo TimeZone { get; }
Property Value
Year
Year component.
public int Year { get; }
Property Value
Methods
Add(Period)
Creates a new ZonedDay instance by adding value
to this instance.
[Pure]
public ZonedDay Add(Period value)
Parameters
Returns
AddDays(int)
Creates a new ZonedDay instance by adding provided number of days to this instance.
[Pure]
public ZonedDay AddDays(int days)
Parameters
days
intNumber of days to add.
Returns
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
ZonedDayAn 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
objectAn 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
ZonedDateTimeDate 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
ZonedDateTimeDate time contained by the result.
Returns
Create(DateTime, TimeZoneInfo)
Creates a new ZonedDay instance.
[Pure]
public static ZonedDay Create(DateTime dateTime, TimeZoneInfo timeZone)
Parameters
dateTime
DateTimeDate time contained by the result.
timeZone
TimeZoneInfoTarget time zone.
Returns
CreateLocal(DateTime)
[Pure]
public static ZonedDay CreateLocal(DateTime localDateTime)
Parameters
localDateTime
DateTimeDate time contained by the result.
Returns
CreateUtc(Timestamp)
[Pure]
public static ZonedDay CreateUtc(Timestamp timestamp)
Parameters
timestamp
TimestampTimestamp contained by the result.
Returns
CreateUtc(DateTime)
[Pure]
public static ZonedDay CreateUtc(DateTime utcDateTime)
Parameters
utcDateTime
DateTimeDate time contained by the result.
Returns
Equals(ZonedDay)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(ZonedDay other)
Parameters
other
ZonedDayAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
[Pure]
public override bool Equals(object? obj)
Parameters
obj
objectThe 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
TimeOfDayTime 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
ZonedDayStart day.
units
PeriodUnitsPeriodUnits to include in the calculated difference.
Returns
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
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
ZonedDayStart day.
units
PeriodUnitsPeriodUnits to include in the calculated difference.
Returns
GetPrevious()
Creates a new ZonedDay instance by calculating the previous day.
[Pure]
public ZonedDay GetPrevious()
Returns
GetWeek(IsoDayOfWeek)
Creates a new ZonedWeek instance that contains this instance.
[Pure]
public ZonedWeek GetWeek(IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
weekStart
IsoDayOfWeekFirst day of the week.
Returns
GetYear()
Creates a new ZonedYear instance that contains this instance.
[Pure]
public ZonedYear GetYear()
Returns
SetDayOfMonth(int)
Creates a new ZonedDay instance by setting the DayOfMonth component in this instance.
[Pure]
public ZonedDay SetDayOfMonth(int day)
Parameters
day
intDay of month to set.
Returns
Exceptions
- ArgumentOutOfRangeException
When
day
is not valid for the current month.
SetDayOfYear(int)
[Pure]
public ZonedDay SetDayOfYear(int day)
Parameters
day
intDay of year to set.
Returns
Exceptions
- ArgumentOutOfRangeException
When
day
is not valid for the current year.
SetMonth(IsoMonthOfYear)
[Pure]
public ZonedDay SetMonth(IsoMonthOfYear month)
Parameters
month
IsoMonthOfYearMonth to set.
Returns
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)
[Pure]
public ZonedDay SetYear(int year)
Parameters
year
intYear to set.
Returns
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
Returns
SubtractDays(int)
Creates a new ZonedDay instance by subtracting provided number of days from this instance.
[Pure]
public ZonedDay SubtractDays(int days)
Parameters
days
intNumber of days to subtract.
Returns
ToBounds()
[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()
[Pure]
public ZonedDay ToLocalTimeZone()
Returns
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
TimeZoneInfoTarget time zone.
Returns
ToUtcTimeZone()
[Pure]
public ZonedDay ToUtcTimeZone()
Returns
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
TimeOfDayTime 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
Returns
operator ==(ZonedDay, ZonedDay)
Checks if a
is equal to b
.
[Pure]
public static bool operator ==(ZonedDay a, ZonedDay b)
Parameters
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
ZonedDayValue to convert.
Returns
explicit operator DateTime(ZonedDay)
Converts the provided source
to DateTime.
[Pure]
public static explicit operator DateTime(ZonedDay source)
Parameters
source
ZonedDayValue to convert.
Returns
operator >(ZonedDay, ZonedDay)
Checks if a
is greater than b
.
[Pure]
public static bool operator >(ZonedDay a, ZonedDay b)
Parameters
Returns
- bool
true when
a
is greater thanb
, 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
Returns
- bool
true when
a
is greater than or equal tob
, otherwise false.
operator !=(ZonedDay, ZonedDay)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(ZonedDay a, ZonedDay b)
Parameters
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
Returns
- bool
true when
a
is less thanb
, 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
Returns
- bool
true when
a
is less than or equal tob
, otherwise false.
operator -(ZonedDay, Period)
Creates a new ZonedDay instance by subtracting b
from a
.
[Pure]
public static ZonedDay operator -(ZonedDay a, Period b)