Table of Contents

Struct ZonedMonth

Namespace
LfrlAnvil.Chrono
Assembly
LfrlAnvil.Chrono.dll

Represents a month with time zone.

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

Properties

DayCount

Number of days in this month.

public int DayCount { get; }

Property Value

int

Duration

Duration of this month.

public Duration Duration { get; }

Property Value

Duration

End

End of this month.

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

IsoMonthOfYear descriptor of this month.

public IsoMonthOfYear Month { get; }

Property Value

IsoMonthOfYear

Start

Start of this month.

public ZonedDateTime Start { get; }

Property Value

ZonedDateTime

TimeZone

Time zone of this month.

public TimeZoneInfo TimeZone { get; }

Property Value

TimeZoneInfo

Year

Year component.

public int Year { get; }

Property Value

int

Methods

Add(Period)

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

[Pure]
public ZonedMonth Add(Period value)

Parameters

value Period

Period to add.

Returns

ZonedMonth

New ZonedMonth instance.

AddMonths(int)

Creates a new ZonedMonth instance by adding provided number of months to this instance.

[Pure]
public ZonedMonth AddMonths(int months)

Parameters

months int

Number of months to add.

Returns

ZonedMonth

New ZonedMonth instance.

CompareTo(ZonedMonth)

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(ZonedMonth other)

Parameters

other ZonedMonth

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

[Pure]
public bool Contains(ZonedDateTime dateTime)

Parameters

dateTime ZonedDateTime

Date time to check.

Returns

bool

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

Contains(ZonedDay)

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

[Pure]
public bool Contains(ZonedDay day)

Parameters

day ZonedDay

Day to check.

Returns

bool

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

Create(ZonedDateTime)

Creates a new ZonedMonth instance.

[Pure]
public static ZonedMonth Create(ZonedDateTime dateTime)

Parameters

dateTime ZonedDateTime

Date time contained by the result.

Returns

ZonedMonth

New ZonedMonth instance.

Create(ZonedDay)

Creates a new ZonedMonth instance.

[Pure]
public static ZonedMonth Create(ZonedDay day)

Parameters

day ZonedDay

Day contained by the result.

Returns

ZonedMonth

New ZonedMonth instance.

Create(DateTime, TimeZoneInfo)

Creates a new ZonedMonth instance.

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

Parameters

dateTime DateTime

Date time contained by the result.

timeZone TimeZoneInfo

Target time zone.

Returns

ZonedMonth

New ZonedMonth instance.

Create(int, IsoMonthOfYear, TimeZoneInfo)

Creates a new ZonedMonth instance.

[Pure]
public static ZonedMonth Create(int year, IsoMonthOfYear month, TimeZoneInfo timeZone)

Parameters

year int

Year component.

month IsoMonthOfYear

Month component.

timeZone TimeZoneInfo

Target time zone.

Returns

ZonedMonth

New ZonedMonth instance.

Exceptions

ArgumentOutOfRangeException

When year is not valid.

CreateLocal(DateTime)

Creates a new ZonedMonth instance in Local time zone.

[Pure]
public static ZonedMonth CreateLocal(DateTime localDateTime)

Parameters

localDateTime DateTime

Date time contained by the result.

Returns

ZonedMonth

New ZonedMonth instance.

CreateLocal(int, IsoMonthOfYear)

Creates a new ZonedMonth instance in Local time zone.

[Pure]
public static ZonedMonth CreateLocal(int year, IsoMonthOfYear month)

Parameters

year int

Year component.

month IsoMonthOfYear

Month component.

Returns

ZonedMonth

New ZonedMonth instance.

Exceptions

ArgumentOutOfRangeException

When year is not valid.

CreateUtc(Timestamp)

Creates a new ZonedMonth instance in Utc time zone.

[Pure]
public static ZonedMonth CreateUtc(Timestamp timestamp)

Parameters

timestamp Timestamp

Timestamp contained by the result.

Returns

ZonedMonth

New ZonedMonth instance.

CreateUtc(DateTime)

Creates a new ZonedMonth instance in Utc time zone.

[Pure]
public static ZonedMonth CreateUtc(DateTime utcDateTime)

Parameters

utcDateTime DateTime

Date time contained by the result.

Returns

ZonedMonth

New ZonedMonth instance.

CreateUtc(int, IsoMonthOfYear)

Creates a new ZonedMonth instance in Utc time zone.

[Pure]
public static ZonedMonth CreateUtc(int year, IsoMonthOfYear month)

Parameters

year int

Year component.

month IsoMonthOfYear

Month component.

Returns

ZonedMonth

New ZonedMonth instance.

Exceptions

ArgumentOutOfRangeException

When year is not valid.

Equals(ZonedMonth)

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

[Pure]
public bool Equals(ZonedMonth other)

Parameters

other ZonedMonth

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 month in order.

[Pure]
public IEnumerable<ZonedDay> GetAllDays()

Returns

IEnumerable<ZonedDay>

New IEnumerable<T> instance.

GetAllWeeks(IsoDayOfWeek)

Creates a new IEnumerable<T> instance that contains all weeks of this month 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.

GetDayOfMonth(int)

Creates a new ZonedDay instance that represents the specified dayOfMonth of this month.

[Pure]
public ZonedDay GetDayOfMonth(int dayOfMonth)

Parameters

dayOfMonth int

Day of this month to get.

Returns

ZonedDay

New ZonedDay instance.

Exceptions

ArgumentOutOfRangeException

When dayOfMonth is not valid.

GetGreedyPeriodOffset(ZonedMonth, 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(ZonedMonth start, PeriodUnits units)

Parameters

start ZonedMonth

Start month.

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.

GetNext()

Creates a new ZonedMonth instance by calculating the next month.

[Pure]
public ZonedMonth GetNext()

Returns

ZonedMonth

New ZonedMonth instance.

GetPeriodOffset(ZonedMonth, 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(ZonedMonth start, PeriodUnits units)

Parameters

start ZonedMonth

Start month.

units PeriodUnits

PeriodUnits to include in the calculated difference.

Returns

Period

New Period instance.

GetPrevious()

Creates a new ZonedMonth instance by calculating the previous month.

[Pure]
public ZonedMonth GetPrevious()

Returns

ZonedMonth

New ZonedMonth instance.

GetWeekCount(IsoDayOfWeek)

Calculates the number of weeks in this month.

[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 month.

GetWeekOfMonth(int, IsoDayOfWeek)

Creates a new ZonedWeek instance that represents the specified weekOfMonth of this month.

[Pure]
public ZonedWeek GetWeekOfMonth(int weekOfMonth, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

weekOfMonth int

Week of this month to get.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

Exceptions

ArgumentOutOfRangeException

When weekOfMonth is not valid.

GetYear()

Creates a new ZonedYear instance that contains this instance.

[Pure]
public ZonedYear GetYear()

Returns

ZonedYear

New ZonedYear instance.

SetMonth(IsoMonthOfYear)

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

[Pure]
public ZonedMonth SetMonth(IsoMonthOfYear month)

Parameters

month IsoMonthOfYear

Month to set.

Returns

ZonedMonth

New ZonedMonth instance.

SetYear(int)

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

[Pure]
public ZonedMonth SetYear(int year)

Parameters

year int

Year to set.

Returns

ZonedMonth

New ZonedMonth instance.

Exceptions

ArgumentOutOfRangeException

When year is not valid.

Subtract(Period)

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

[Pure]
public ZonedMonth Subtract(Period value)

Parameters

value Period

Period to subtract.

Returns

ZonedMonth

New ZonedMonth instance.

SubtractMonths(int)

Creates a new ZonedMonth instance by subtracting provided number of months from this instance.

[Pure]
public ZonedMonth SubtractMonths(int months)

Parameters

months int

Number of months to subtract.

Returns

ZonedMonth

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

[Pure]
public ZonedMonth ToLocalTimeZone()

Returns

ZonedMonth

New ZonedMonth instance.

ToString()

Returns a string representation of this ZonedMonth instance.

[Pure]
public override string ToString()

Returns

string

String representation.

ToTimeZone(TimeZoneInfo)

Creates a new ZonedMonth in the targetTimeZone from this instance.

[Pure]
public ZonedMonth ToTimeZone(TimeZoneInfo targetTimeZone)

Parameters

targetTimeZone TimeZoneInfo

Target time zone.

Returns

ZonedMonth

New ZonedMonth instance.

ToUtcTimeZone()

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

[Pure]
public ZonedMonth ToUtcTimeZone()

Returns

ZonedMonth

New ZonedMonth instance.

TryGetDayOfMonth(int)

Attempts to create a new ZonedDay instance that represents the specified dayOfMonth of this month.

[Pure]
public ZonedDay? TryGetDayOfMonth(int dayOfMonth)

Parameters

dayOfMonth int

Day of this month to get.

Returns

ZonedDay?

New ZonedDay instance or null when dayOfMonth is not valid.

TryGetWeekOfMonth(int, IsoDayOfWeek)

Attempts to create a new ZonedWeek instance that represents the specified weekOfMonth of this month.

[Pure]
public ZonedWeek? TryGetWeekOfMonth(int weekOfMonth, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

weekOfMonth int

Week of this month to get.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek?

New ZonedWeek instance or null when weekOfMonth is not valid.

Operators

operator +(ZonedMonth, Period)

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

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

Parameters

a ZonedMonth

First operand.

b Period

Second operand.

Returns

ZonedMonth

New ZonedMonth instance.

operator ==(ZonedMonth, ZonedMonth)

Checks if a is equal to b.

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

Parameters

a ZonedMonth

First operand.

b ZonedMonth

Second operand.

Returns

bool

true when operands are equal, otherwise false.

operator >(ZonedMonth, ZonedMonth)

Checks if a is greater than b.

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

Parameters

a ZonedMonth

First operand.

b ZonedMonth

Second operand.

Returns

bool

true when a is greater than b, otherwise false.

operator >=(ZonedMonth, ZonedMonth)

Checks if a is greater than or equal to b.

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

Parameters

a ZonedMonth

First operand.

b ZonedMonth

Second operand.

Returns

bool

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

operator !=(ZonedMonth, ZonedMonth)

Checks if a is not equal to b.

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

Parameters

a ZonedMonth

First operand.

b ZonedMonth

Second operand.

Returns

bool

true when operands are not equal, otherwise false.

operator <(ZonedMonth, ZonedMonth)

Checks if a is less than b.

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

Parameters

a ZonedMonth

First operand.

b ZonedMonth

Second operand.

Returns

bool

true when a is less than b, otherwise false.

operator <=(ZonedMonth, ZonedMonth)

Checks if a is less than or equal to b.

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

Parameters

a ZonedMonth

First operand.

b ZonedMonth

Second operand.

Returns

bool

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

operator -(ZonedMonth, Period)

Creates a new ZonedMonth instance by subtracting b from a.

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

Parameters

a ZonedMonth

First operand.

b Period

Second operand.

Returns

ZonedMonth

New ZonedMonth instance.