Table of Contents

Struct ZonedYear

Namespace
LfrlAnvil.Chrono
Assembly
LfrlAnvil.Chrono.dll

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

int

Duration

Duration of this year.

public Duration Duration { get; }

Property Value

Duration

End

End of this year.

public ZonedDateTime End { get; }

Property Value

ZonedDateTime

IsLeap

Specifies whether or not this year is a leap year.

public bool IsLeap { get; }

Property Value

bool

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

Start

Start of this year.

public ZonedDateTime Start { get; }

Property Value

ZonedDateTime

TimeZone

Time zone of this year.

public TimeZoneInfo TimeZone { get; }

Property Value

TimeZoneInfo

Year

Year component.

public int Year { get; }

Property Value

int

Methods

Add(Period)

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

[Pure]
public ZonedYear Add(Period value)

Parameters

value Period

Period to add.

Returns

ZonedYear

New ZonedYear instance.

AddYears(int)

Creates a new ZonedYear instance by adding provided number of years to this instance.

[Pure]
public ZonedYear AddYears(int years)

Parameters

years int

Number of years to add.

Returns

ZonedYear

New ZonedYear instance.

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 ZonedYear

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 year.

[Pure]
public bool Contains(ZonedDateTime dateTime)

Parameters

dateTime ZonedDateTime

Date 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 ZonedDay

Day 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 ZonedMonth

Month 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 ZonedDateTime

Date time contained by the result.

Returns

ZonedYear

New ZonedYear instance.

Create(ZonedDay)

Creates a new ZonedYear instance.

[Pure]
public static ZonedYear Create(ZonedDay day)

Parameters

day ZonedDay

Day contained by the result.

Returns

ZonedYear

New ZonedYear instance.

Create(ZonedMonth)

Creates a new ZonedYear instance.

[Pure]
public static ZonedYear Create(ZonedMonth month)

Parameters

month ZonedMonth

Month contained by the result.

Returns

ZonedYear

New ZonedYear instance.

Create(DateTime, TimeZoneInfo)

Creates a new ZonedYear instance.

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

Parameters

dateTime DateTime

Date time contained by the result.

timeZone TimeZoneInfo

Target time zone.

Returns

ZonedYear

New ZonedYear instance.

Create(int, TimeZoneInfo)

Creates a new ZonedYear instance.

[Pure]
public static ZonedYear Create(int year, TimeZoneInfo timeZone)

Parameters

year int

Year component.

timeZone TimeZoneInfo

Target time zone.

Returns

ZonedYear

New ZonedYear instance.

Exceptions

ArgumentOutOfRangeException

When year is not valid.

CreateLocal(DateTime)

Creates a new ZonedYear instance in Local time zone.

[Pure]
public static ZonedYear CreateLocal(DateTime localDateTime)

Parameters

localDateTime DateTime

Date time contained by the result.

Returns

ZonedYear

New ZonedYear instance.

CreateLocal(int)

Creates a new ZonedYear instance in Local time zone.

[Pure]
public static ZonedYear CreateLocal(int year)

Parameters

year int

Year component.

Returns

ZonedYear

New ZonedYear instance.

Exceptions

ArgumentOutOfRangeException

When year is not valid.

CreateUtc(Timestamp)

Creates a new ZonedYear instance in Utc time zone.

[Pure]
public static ZonedYear CreateUtc(Timestamp timestamp)

Parameters

timestamp Timestamp

Timestamp contained by the result.

Returns

ZonedYear

New ZonedYear instance.

CreateUtc(DateTime)

Creates a new ZonedYear instance in Utc time zone.

[Pure]
public static ZonedYear CreateUtc(DateTime utcDateTime)

Parameters

utcDateTime DateTime

Date time contained by the result.

Returns

ZonedYear

New ZonedYear instance.

CreateUtc(int)

Creates a new ZonedYear instance in Utc time zone.

[Pure]
public static ZonedYear CreateUtc(int year)

Parameters

year int

Year component.

Returns

ZonedYear

New ZonedYear instance.

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 ZonedYear

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.

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 IsoDayOfWeek

First 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 int

Day of this year to get.

Returns

ZonedDay

New ZonedDay instance.

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 ZonedYear

Start year.

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.

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 IsoMonthOfYear

Month to get.

Returns

ZonedMonth

New ZonedMonth instance.

GetNext()

Creates a new ZonedYear instance by calculating the next year.

[Pure]
public ZonedYear GetNext()

Returns

ZonedYear

New ZonedYear instance.

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 ZonedYear

Start year.

units PeriodUnits

PeriodUnits to include in the calculated difference.

Returns

Period

New Period instance.

GetPrevious()

Creates a new ZonedYear instance by calculating the previous year.

[Pure]
public ZonedYear GetPrevious()

Returns

ZonedYear

New ZonedYear instance.

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 IsoDayOfWeek

First 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 int

Week of this year to get.

weekStart IsoDayOfWeek

First day of the week. Equal to Monday by default.

Returns

ZonedWeek

New ZonedWeek instance.

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

value Period

Period to subtract.

Returns

ZonedYear

New ZonedYear instance.

SubtractYears(int)

Creates a new ZonedYear instance by subtracting provided number of years from this instance.

[Pure]
public ZonedYear SubtractYears(int years)

Parameters

years int

Number of years to subtract.

Returns

ZonedYear

New ZonedYear 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 ZonedYear in Local time zone from this instance.

[Pure]
public ZonedYear ToLocalTimeZone()

Returns

ZonedYear

New ZonedYear instance.

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 TimeZoneInfo

Target time zone.

Returns

ZonedYear

New ZonedYear instance.

ToUtcTimeZone()

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

[Pure]
public ZonedYear ToUtcTimeZone()

Returns

ZonedYear

New ZonedYear instance.

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 int

Day of this year to get.

Returns

ZonedDay?

New ZonedDay instance or null when dayOfYear is not valid.

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 int

Week of this year to get.

weekStart IsoDayOfWeek

First day of the week. Equal to Monday by default.

Returns

ZonedWeek?

New ZonedWeek instance or null when weekOfYear is not valid.

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

a ZonedYear

First operand.

b Period

Second operand.

Returns

ZonedYear

New ZonedYear instance.

operator ==(ZonedYear, ZonedYear)

Checks if a is equal to b.

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

Parameters

a ZonedYear

First operand.

b ZonedYear

Second operand.

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

a ZonedYear

First operand.

b ZonedYear

Second operand.

Returns

bool

true when a is greater than b, 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

a ZonedYear

First operand.

b ZonedYear

Second operand.

Returns

bool

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

operator !=(ZonedYear, ZonedYear)

Checks if a is not equal to b.

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

Parameters

a ZonedYear

First operand.

b ZonedYear

Second operand.

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

a ZonedYear

First operand.

b ZonedYear

Second operand.

Returns

bool

true when a is less than b, 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

a ZonedYear

First operand.

b ZonedYear

Second operand.

Returns

bool

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

operator -(ZonedYear, Period)

Creates a new ZonedYear instance by subtracting b from a.

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

Parameters

a ZonedYear

First operand.

b Period

Second operand.

Returns

ZonedYear

New ZonedYear instance.