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
monthsintNumber 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
otherZonedMonthAn 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 otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin 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
objobjectAn 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 objin the sort order.Zero This instance occurs in the same position in the sort order as obj.Greater than zero This instance follows objin the sort order.
Exceptions
- ArgumentException
objis 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
dateTimeZonedDateTimeDate time to check.
Returns
- bool
true when the provided
dateTimebelongs 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
dayZonedDayDay to check.
Returns
- bool
true when the provided
daybelongs to this month, otherwise false.
Create(ZonedDateTime)
Creates a new ZonedMonth instance.
[Pure]
public static ZonedMonth Create(ZonedDateTime dateTime)
Parameters
dateTimeZonedDateTimeDate 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
dayZonedDayDay 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
dateTimeDateTimeDate time contained by the result.
timeZoneTimeZoneInfoTarget 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
yearintYear component.
monthIsoMonthOfYearMonth component.
timeZoneTimeZoneInfoTarget time zone.
Returns
- ZonedMonth
New ZonedMonth instance.
Exceptions
- ArgumentOutOfRangeException
When
yearis not valid.
CreateLocal(DateTime)
Creates a new ZonedMonth instance in Local time zone.
[Pure]
public static ZonedMonth CreateLocal(DateTime localDateTime)
Parameters
localDateTimeDateTimeDate 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
yearintYear component.
monthIsoMonthOfYearMonth component.
Returns
- ZonedMonth
New ZonedMonth instance.
Exceptions
- ArgumentOutOfRangeException
When
yearis not valid.
CreateUtc(Timestamp)
Creates a new ZonedMonth instance in Utc time zone.
[Pure]
public static ZonedMonth CreateUtc(Timestamp timestamp)
Parameters
timestampTimestampTimestamp 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
utcDateTimeDateTimeDate 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
yearintYear component.
monthIsoMonthOfYearMonth component.
Returns
- ZonedMonth
New ZonedMonth instance.
Exceptions
- ArgumentOutOfRangeException
When
yearis 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
otherZonedMonthAn 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
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
weekStartIsoDayOfWeekFirst 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
dayOfMonthintDay of this month to get.
Returns
Exceptions
- ArgumentOutOfRangeException
When
dayOfMonthis 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
startZonedMonthStart month.
unitsPeriodUnitsPeriodUnits 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
startZonedMonthStart month.
unitsPeriodUnitsPeriodUnits 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
weekStartIsoDayOfWeekFirst 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
weekOfMonthintWeek of this month to get.
weekStartIsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Exceptions
- ArgumentOutOfRangeException
When
weekOfMonthis 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
monthIsoMonthOfYearMonth 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
yearintYear to set.
Returns
- ZonedMonth
New ZonedMonth instance.
Exceptions
- ArgumentOutOfRangeException
When
yearis 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
monthsintNumber 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
targetTimeZoneTimeZoneInfoTarget 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
dayOfMonthintDay 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
weekOfMonthintWeek of this month to get.
weekStartIsoDayOfWeekFirst 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
aZonedMonthFirst operand.
bPeriodSecond 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
aZonedMonthFirst operand.
bZonedMonthSecond 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
aZonedMonthFirst operand.
bZonedMonthSecond operand.
Returns
- bool
true when
ais 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
aZonedMonthFirst operand.
bZonedMonthSecond operand.
Returns
- bool
true when
ais 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
aZonedMonthFirst operand.
bZonedMonthSecond 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
aZonedMonthFirst operand.
bZonedMonthSecond operand.
Returns
- bool
true when
ais 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
aZonedMonthFirst operand.
bZonedMonthSecond operand.
Returns
- bool
true when
ais 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
aZonedMonthFirst operand.
bPeriodSecond operand.
Returns
- ZonedMonth
New ZonedMonth instance.