Struct ZonedMonth
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
Duration
Duration of this month.
public Duration Duration { get; }
Property Value
End
End of this month.
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
IsoMonthOfYear descriptor of this month.
public IsoMonthOfYear Month { get; }
Property Value
Start
Start of this month.
public ZonedDateTime Start { get; }
Property Value
TimeZone
Time zone of this month.
public TimeZoneInfo TimeZone { get; }
Property Value
Year
Year component.
public int Year { get; }
Property Value
Methods
Add(Period)
Creates a new ZonedMonth instance by adding value
to this instance.
[Pure]
public ZonedMonth Add(Period value)
Parameters
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
intNumber 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
ZonedMonthAn 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 month.
[Pure]
public bool Contains(ZonedDateTime dateTime)
Parameters
dateTime
ZonedDateTimeDate 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
ZonedDayDay 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
ZonedDateTimeDate 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
ZonedDayDay 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
DateTimeDate time contained by the result.
timeZone
TimeZoneInfoTarget 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
intYear component.
month
IsoMonthOfYearMonth component.
timeZone
TimeZoneInfoTarget 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
DateTimeDate 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
intYear component.
month
IsoMonthOfYearMonth 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
TimestampTimestamp 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
DateTimeDate 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
intYear component.
month
IsoMonthOfYearMonth 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
ZonedMonthAn 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 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
IsoDayOfWeekFirst 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
intDay of this month to get.
Returns
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
ZonedMonthStart month.
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.
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
ZonedMonthStart month.
units
PeriodUnitsPeriodUnits to include in the calculated difference.
Returns
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
IsoDayOfWeekFirst 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
intWeek of this month to get.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Exceptions
- ArgumentOutOfRangeException
When
weekOfMonth
is not valid.
GetYear()
Creates a new ZonedYear instance that contains this instance.
[Pure]
public ZonedYear GetYear()
Returns
SetMonth(IsoMonthOfYear)
Creates a new ZonedMonth instance by setting the Month component in this instance.
[Pure]
public ZonedMonth SetMonth(IsoMonthOfYear month)
Parameters
month
IsoMonthOfYearMonth 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
intYear 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
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
intNumber of months to subtract.
Returns
- ZonedMonth
New ZonedMonth instance.
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()
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
TimeZoneInfoTarget 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
intDay of this month to get.
Returns
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
intWeek of this month to get.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
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
ZonedMonthFirst operand.
b
PeriodSecond 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
ZonedMonthFirst operand.
b
ZonedMonthSecond 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
ZonedMonthFirst operand.
b
ZonedMonthSecond operand.
Returns
- bool
true when
a
is greater thanb
, 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
ZonedMonthFirst operand.
b
ZonedMonthSecond operand.
Returns
- bool
true when
a
is greater than or equal tob
, otherwise false.
operator !=(ZonedMonth, ZonedMonth)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(ZonedMonth a, ZonedMonth b)
Parameters
a
ZonedMonthFirst operand.
b
ZonedMonthSecond 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
ZonedMonthFirst operand.
b
ZonedMonthSecond operand.
Returns
- bool
true when
a
is less thanb
, 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
ZonedMonthFirst operand.
b
ZonedMonthSecond operand.
Returns
- bool
true when
a
is less than or equal tob
, 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
ZonedMonthFirst operand.
b
PeriodSecond operand.
Returns
- ZonedMonth
New ZonedMonth instance.