Struct ZonedYear
Represents a year with time zone.
public readonly struct ZonedYear : IEquatable<ZonedYear>, IComparable<ZonedYear>, IComparable
- Implements
- Inherited Members
Properties
DayCount
Number of days in this year.
public int DayCount { get; }
Property Value
Duration
Duration of this year.
public Duration Duration { get; }
Property Value
End
End of this year.
public ZonedDateTime End { get; }
Property Value
IsLeap
Specifies whether or not this year is a leap year.
public bool IsLeap { 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
Start
Start of this year.
public ZonedDateTime Start { get; }
Property Value
TimeZone
Time zone of this year.
public TimeZoneInfo TimeZone { get; }
Property Value
Year
Year component.
public int Year { get; }
Property Value
Methods
Add(Period)
Creates a new ZonedYear instance by adding value
to this instance.
[Pure]
public ZonedYear Add(Period value)
Parameters
Returns
AddYears(int)
Creates a new ZonedYear instance by adding provided number of years to this instance.
[Pure]
public ZonedYear AddYears(int years)
Parameters
years
intNumber of years to add.
Returns
CompareTo(ZonedYear)
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(ZonedYear other)
Parameters
other
ZonedYearAn 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 year.
[Pure]
public bool Contains(ZonedDateTime dateTime)
Parameters
dateTime
ZonedDateTimeDate time to check.
Returns
- bool
true when the provided
dateTime
belongs to this year, otherwise false.
Contains(ZonedDay)
Checks whether or not the provided day
belongs to this year.
[Pure]
public bool Contains(ZonedDay day)
Parameters
day
ZonedDayDay to check.
Returns
- bool
true when the provided
day
belongs to this year, otherwise false.
Contains(ZonedMonth)
Checks whether or not the provided month
belongs to this year.
[Pure]
public bool Contains(ZonedMonth month)
Parameters
month
ZonedMonthMonth to check.
Returns
- bool
true when the provided
month
belongs to this year, otherwise false.
Create(ZonedDateTime)
Creates a new ZonedYear instance.
[Pure]
public static ZonedYear Create(ZonedDateTime dateTime)
Parameters
dateTime
ZonedDateTimeDate time contained by the result.
Returns
Create(ZonedDay)
Creates a new ZonedYear instance.
[Pure]
public static ZonedYear Create(ZonedDay day)
Parameters
day
ZonedDayDay contained by the result.
Returns
Create(ZonedMonth)
Creates a new ZonedYear instance.
[Pure]
public static ZonedYear Create(ZonedMonth month)
Parameters
month
ZonedMonthMonth contained by the result.
Returns
Create(DateTime, TimeZoneInfo)
Creates a new ZonedYear instance.
[Pure]
public static ZonedYear Create(DateTime dateTime, TimeZoneInfo timeZone)
Parameters
dateTime
DateTimeDate time contained by the result.
timeZone
TimeZoneInfoTarget time zone.
Returns
Create(int, TimeZoneInfo)
Creates a new ZonedYear instance.
[Pure]
public static ZonedYear Create(int year, TimeZoneInfo timeZone)
Parameters
year
intYear component.
timeZone
TimeZoneInfoTarget time zone.
Returns
Exceptions
- ArgumentOutOfRangeException
When
year
is not valid.
CreateLocal(DateTime)
[Pure]
public static ZonedYear CreateLocal(DateTime localDateTime)
Parameters
localDateTime
DateTimeDate time contained by the result.
Returns
CreateLocal(int)
[Pure]
public static ZonedYear CreateLocal(int year)
Parameters
year
intYear component.
Returns
Exceptions
- ArgumentOutOfRangeException
When
year
is not valid.
CreateUtc(Timestamp)
[Pure]
public static ZonedYear CreateUtc(Timestamp timestamp)
Parameters
timestamp
TimestampTimestamp contained by the result.
Returns
CreateUtc(DateTime)
[Pure]
public static ZonedYear CreateUtc(DateTime utcDateTime)
Parameters
utcDateTime
DateTimeDate time contained by the result.
Returns
CreateUtc(int)
[Pure]
public static ZonedYear CreateUtc(int year)
Parameters
year
intYear component.
Returns
Exceptions
- ArgumentOutOfRangeException
When
year
is not valid.
Equals(ZonedYear)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(ZonedYear other)
Parameters
other
ZonedYearAn 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.
GetAllDays()
Creates a new IEnumerable<T> instance that contains all days of this year in order.
[Pure]
public IEnumerable<ZonedDay> GetAllDays()
Returns
- IEnumerable<ZonedDay>
New IEnumerable<T> instance.
GetAllMonths()
Creates a new IEnumerable<T> instance that contains all months of this year in order.
[Pure]
public IEnumerable<ZonedMonth> GetAllMonths()
Returns
- IEnumerable<ZonedMonth>
New IEnumerable<T> instance.
GetAllWeeks(IsoDayOfWeek)
Creates a new IEnumerable<T> instance that contains all weeks of this year in order.
[Pure]
public IEnumerable<ZonedWeek> GetAllWeeks(IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
- IEnumerable<ZonedWeek>
New IEnumerable<T> instance.
GetApril()
Creates a new ZonedMonth instance that represents April of this year.
[Pure]
public ZonedMonth GetApril()
Returns
- ZonedMonth
New ZonedMonth instance.
GetAugust()
Creates a new ZonedMonth instance that represents August of this year.
[Pure]
public ZonedMonth GetAugust()
Returns
- ZonedMonth
New ZonedMonth instance.
GetDayOfYear(int)
Creates a new ZonedDay instance that represents the specified dayOfYear
of this year.
[Pure]
public ZonedDay GetDayOfYear(int dayOfYear)
Parameters
dayOfYear
intDay of this year to get.
Returns
Exceptions
- ArgumentOutOfRangeException
When
dayOfYear
is not valid.
GetDecember()
Creates a new ZonedMonth instance that represents December of this year.
[Pure]
public ZonedMonth GetDecember()
Returns
- ZonedMonth
New ZonedMonth instance.
GetFebruary()
Creates a new ZonedMonth instance that represents February of this year.
[Pure]
public ZonedMonth GetFebruary()
Returns
- ZonedMonth
New ZonedMonth instance.
GetGreedyPeriodOffset(ZonedYear, 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(ZonedYear start, PeriodUnits units)
Parameters
start
ZonedYearStart year.
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.
GetJanuary()
Creates a new ZonedMonth instance that represents January of this year.
[Pure]
public ZonedMonth GetJanuary()
Returns
- ZonedMonth
New ZonedMonth instance.
GetJuly()
Creates a new ZonedMonth instance that represents July of this year.
[Pure]
public ZonedMonth GetJuly()
Returns
- ZonedMonth
New ZonedMonth instance.
GetJune()
Creates a new ZonedMonth instance that represents June of this year.
[Pure]
public ZonedMonth GetJune()
Returns
- ZonedMonth
New ZonedMonth instance.
GetMarch()
Creates a new ZonedMonth instance that represents March of this year.
[Pure]
public ZonedMonth GetMarch()
Returns
- ZonedMonth
New ZonedMonth instance.
GetMay()
Creates a new ZonedMonth instance that represents May of this year.
[Pure]
public ZonedMonth GetMay()
Returns
- ZonedMonth
New ZonedMonth instance.
GetMonth(IsoMonthOfYear)
Creates a new ZonedMonth instance that represents the specified month
of this year.
[Pure]
public ZonedMonth GetMonth(IsoMonthOfYear month)
Parameters
month
IsoMonthOfYearMonth to get.
Returns
- ZonedMonth
New ZonedMonth instance.
GetNext()
Creates a new ZonedYear instance by calculating the next year.
[Pure]
public ZonedYear GetNext()
Returns
GetNovember()
Creates a new ZonedMonth instance that represents November of this year.
[Pure]
public ZonedMonth GetNovember()
Returns
- ZonedMonth
New ZonedMonth instance.
GetOctober()
Creates a new ZonedMonth instance that represents October of this year.
[Pure]
public ZonedMonth GetOctober()
Returns
- ZonedMonth
New ZonedMonth instance.
GetPeriodOffset(ZonedYear, 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(ZonedYear start, PeriodUnits units)
Parameters
start
ZonedYearStart year.
units
PeriodUnitsPeriodUnits to include in the calculated difference.
Returns
GetPrevious()
Creates a new ZonedYear instance by calculating the previous year.
[Pure]
public ZonedYear GetPrevious()
Returns
GetSeptember()
Creates a new ZonedMonth instance that represents September of this year.
[Pure]
public ZonedMonth GetSeptember()
Returns
- ZonedMonth
New ZonedMonth instance.
GetWeekCount(IsoDayOfWeek)
Calculates the number of weeks in this year.
[Pure]
public int GetWeekCount(IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
- int
Number of weeks in this year.
GetWeekOfYear(int, IsoDayOfWeek)
Creates a new ZonedWeek instance that represents the specified weekOfYear
of this year.
[Pure]
public ZonedWeek GetWeekOfYear(int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
weekOfYear
intWeek of this year to get.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Exceptions
- ArgumentOutOfRangeException
When
weekOfYear
is not valid.
Subtract(Period)
Creates a new ZonedYear instance by subtracting value
from this instance.
[Pure]
public ZonedYear Subtract(Period value)
Parameters
Returns
SubtractYears(int)
Creates a new ZonedYear instance by subtracting provided number of years from this instance.
[Pure]
public ZonedYear SubtractYears(int years)
Parameters
years
intNumber of years 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 ZonedYear ToLocalTimeZone()
Returns
ToString()
Returns a string representation of this ZonedYear instance.
[Pure]
public override string ToString()
Returns
- string
String representation.
ToTimeZone(TimeZoneInfo)
Creates a new ZonedYear in the targetTimeZone
from this instance.
[Pure]
public ZonedYear ToTimeZone(TimeZoneInfo targetTimeZone)
Parameters
targetTimeZone
TimeZoneInfoTarget time zone.
Returns
ToUtcTimeZone()
[Pure]
public ZonedYear ToUtcTimeZone()
Returns
TryGetDayOfYear(int)
Attempts to create a new ZonedDay instance that represents the specified dayOfYear
of this year.
[Pure]
public ZonedDay? TryGetDayOfYear(int dayOfYear)
Parameters
dayOfYear
intDay of this year to get.
Returns
TryGetWeekOfYear(int, IsoDayOfWeek)
Attempts to create a new ZonedWeek instance
that represents the specified weekOfYear
of this year.
[Pure]
public ZonedWeek? TryGetWeekOfYear(int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
weekOfYear
intWeek of this year to get.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Operators
operator +(ZonedYear, Period)
Creates a new ZonedYear instance by adding a
and b
together.
[Pure]
public static ZonedYear operator +(ZonedYear a, Period b)
Parameters
Returns
operator ==(ZonedYear, ZonedYear)
Checks if a
is equal to b
.
[Pure]
public static bool operator ==(ZonedYear a, ZonedYear b)
Parameters
Returns
- bool
true when operands are equal, otherwise false.
operator >(ZonedYear, ZonedYear)
Checks if a
is greater than b
.
[Pure]
public static bool operator >(ZonedYear a, ZonedYear b)
Parameters
Returns
- bool
true when
a
is greater thanb
, otherwise false.
operator >=(ZonedYear, ZonedYear)
Checks if a
is greater than or equal to b
.
[Pure]
public static bool operator >=(ZonedYear a, ZonedYear b)
Parameters
Returns
- bool
true when
a
is greater than or equal tob
, otherwise false.
operator !=(ZonedYear, ZonedYear)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(ZonedYear a, ZonedYear b)
Parameters
Returns
- bool
true when operands are not equal, otherwise false.
operator <(ZonedYear, ZonedYear)
Checks if a
is less than b
.
[Pure]
public static bool operator <(ZonedYear a, ZonedYear b)
Parameters
Returns
- bool
true when
a
is less thanb
, otherwise false.
operator <=(ZonedYear, ZonedYear)
Checks if a
is less than or equal to b
.
[Pure]
public static bool operator <=(ZonedYear a, ZonedYear b)
Parameters
Returns
- bool
true when
a
is less than or equal tob
, otherwise false.
operator -(ZonedYear, Period)
Creates a new ZonedYear instance by subtracting b
from a
.
[Pure]
public static ZonedYear operator -(ZonedYear a, Period b)