Struct ZonedWeek
Represents a week with time zone.
public readonly struct ZonedWeek : IEquatable<ZonedWeek>, IComparable<ZonedWeek>, IComparable
- Implements
- Inherited Members
Properties
Duration
Duration of this week.
public Duration Duration { get; }
Property Value
End
End of this week.
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
Start
Start of this week.
public ZonedDateTime Start { get; }
Property Value
TimeZone
Time zone of this week.
public TimeZoneInfo TimeZone { get; }
Property Value
WeekOfYear
Week of year component.
public int WeekOfYear { get; }
Property Value
Year
Year component.
public int Year { get; }
Property Value
Methods
Add(Period)
Creates a new ZonedWeek instance by adding value
to this instance.
[Pure]
public ZonedWeek Add(Period value)
Parameters
Returns
AddWeeks(int)
Creates a new ZonedWeek instance by adding provided number of weeks to this instance.
[Pure]
public ZonedWeek AddWeeks(int weeks)
Parameters
weeks
intNumber of weeks to add.
Returns
CompareTo(ZonedWeek)
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(ZonedWeek other)
Parameters
other
ZonedWeekAn 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 week.
[Pure]
public bool Contains(ZonedDateTime dateTime)
Parameters
dateTime
ZonedDateTimeDate time to check.
Returns
- bool
true when the provided
dateTime
belongs to this week, otherwise false.
Contains(ZonedDay)
Checks whether or not the provided day
belongs to this week.
[Pure]
public bool Contains(ZonedDay day)
Parameters
day
ZonedDayDay to check.
Returns
- bool
true when the provided
day
belongs to this week, otherwise false.
Create(ZonedDateTime, IsoDayOfWeek)
Creates a new ZonedWeek instance.
[Pure]
public static ZonedWeek Create(ZonedDateTime dateTime, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
dateTime
ZonedDateTimeDate time contained by the result.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Create(ZonedDay, IsoDayOfWeek)
Creates a new ZonedWeek instance.
[Pure]
public static ZonedWeek Create(ZonedDay day, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
day
ZonedDayDay contained by the result.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Create(DateTime, TimeZoneInfo, IsoDayOfWeek)
Creates a new ZonedWeek instance.
[Pure]
public static ZonedWeek Create(DateTime dateTime, TimeZoneInfo timeZone, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
dateTime
DateTimeDate time contained by the result.
timeZone
TimeZoneInfoTarget time zone.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Create(int, int, TimeZoneInfo, IsoDayOfWeek)
Creates a new ZonedWeek instance.
[Pure]
public static ZonedWeek Create(int year, int weekOfYear, TimeZoneInfo timeZone, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
year
intYear component of the week.
weekOfYear
intNumber of the week in year.
timeZone
TimeZoneInfoTarget time zone.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Exceptions
- ArgumentOutOfRangeException
When
weekOfYear
is less than 1 or greater than the maximum week number in the specifiedyear
.
CreateLocal(DateTime, IsoDayOfWeek)
[Pure]
public static ZonedWeek CreateLocal(DateTime localDateTime, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
localDateTime
DateTimeDate time contained by the result.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
CreateLocal(int, int, IsoDayOfWeek)
[Pure]
public static ZonedWeek CreateLocal(int year, int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
year
intYear component of the week.
weekOfYear
intNumber of the week in year.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Exceptions
- ArgumentOutOfRangeException
When
weekOfYear
is less than 1 or greater than the maximum week number in the specifiedyear
.
CreateUtc(Timestamp, IsoDayOfWeek)
[Pure]
public static ZonedWeek CreateUtc(Timestamp timestamp, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
timestamp
TimestampTimestamp contained by the result.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
CreateUtc(DateTime, IsoDayOfWeek)
[Pure]
public static ZonedWeek CreateUtc(DateTime utcDateTime, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
utcDateTime
DateTimeDate time contained by the result.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
CreateUtc(int, int, IsoDayOfWeek)
[Pure]
public static ZonedWeek CreateUtc(int year, int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
year
intYear component of the week.
weekOfYear
intNumber of the week in year.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
Exceptions
- ArgumentOutOfRangeException
When
weekOfYear
is less than 1 or greater than the maximum week number in the specifiedyear
.
Equals(ZonedWeek)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(ZonedWeek other)
Parameters
other
ZonedWeekAn 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 week in order.
[Pure]
public IEnumerable<ZonedDay> GetAllDays()
Returns
- IEnumerable<ZonedDay>
New IEnumerable<T> instance.
GetDayOfWeek(IsoDayOfWeek)
Creates a new ZonedDay instance that represents the specified day
of this week.
[Pure]
public ZonedDay GetDayOfWeek(IsoDayOfWeek day)
Parameters
day
IsoDayOfWeekDay of this week to get.
Returns
GetFriday()
[Pure]
public ZonedDay GetFriday()
Returns
GetGreedyPeriodOffset(ZonedWeek, 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(ZonedWeek start, PeriodUnits units)
Parameters
start
ZonedWeekStart week.
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.
GetMonday()
[Pure]
public ZonedDay GetMonday()
Returns
GetNext()
Creates a new ZonedWeek instance by calculating the next week.
[Pure]
public ZonedWeek GetNext()
Returns
GetPeriodOffset(ZonedWeek, 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(ZonedWeek start, PeriodUnits units)
Parameters
start
ZonedWeekStart week.
units
PeriodUnitsPeriodUnits to include in the calculated difference.
Returns
GetPrevious()
Creates a new ZonedWeek instance by calculating the previous week.
[Pure]
public ZonedWeek GetPrevious()
Returns
GetSaturday()
[Pure]
public ZonedDay GetSaturday()
Returns
GetSunday()
[Pure]
public ZonedDay GetSunday()
Returns
GetThursday()
[Pure]
public ZonedDay GetThursday()
Returns
GetTuesday()
[Pure]
public ZonedDay GetTuesday()
Returns
GetWednesday()
[Pure]
public ZonedDay GetWednesday()
Returns
GetYear()
Creates a new ZonedYear instance that contains this instance.
[Pure]
public ZonedYear GetYear()
Returns
SetWeekOfYear(int)
Creates a new ZonedWeek instance by setting the WeekOfYear component in this instance.
[Pure]
public ZonedWeek SetWeekOfYear(int week)
Parameters
week
intWeek of year to set.
Returns
Exceptions
- ArgumentOutOfRangeException
When
week
is not valid.
SetWeekStart(IsoDayOfWeek)
Creates a new ZonedWeek instance by setting new first day of the week in this instance.
[Pure]
public ZonedWeek SetWeekStart(IsoDayOfWeek weekStart)
Parameters
weekStart
IsoDayOfWeekFirst day of the week to set.
Returns
Exceptions
- ArgumentOutOfRangeException
When
weekStart
results in the creation of an invalid week.
SetYear(int)
[Pure]
public ZonedWeek SetYear(int year)
Parameters
year
intYear to set.
Returns
Remarks
Result may end up with modified components other than the year, if it lands in the range of invalid values of this instance's TimeZone.
Exceptions
- ArgumentOutOfRangeException
When
year
is not valid.
Subtract(Period)
Creates a new ZonedWeek instance by subtracting value
from this instance.
[Pure]
public ZonedWeek Subtract(Period value)
Parameters
Returns
SubtractWeeks(int)
Creates a new ZonedWeek instance by subtracting provided number of weeks from this instance.
[Pure]
public ZonedWeek SubtractWeeks(int weeks)
Parameters
weeks
intNumber of weeks 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 ZonedWeek ToLocalTimeZone()
Returns
ToString()
Returns a string representation of this ZonedWeek instance.
[Pure]
public override string ToString()
Returns
- string
String representation.
ToTimeZone(TimeZoneInfo)
Creates a new ZonedWeek in the targetTimeZone
from this instance.
[Pure]
public ZonedWeek ToTimeZone(TimeZoneInfo targetTimeZone)
Parameters
targetTimeZone
TimeZoneInfoTarget time zone.
Returns
ToUtcTimeZone()
[Pure]
public ZonedWeek ToUtcTimeZone()
Returns
TryCreate(int, int, TimeZoneInfo, IsoDayOfWeek)
Attempts to create a new ZonedWeek instance.
[Pure]
public static ZonedWeek? TryCreate(int year, int weekOfYear, TimeZoneInfo timeZone, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
year
intYear component of the week.
weekOfYear
intNumber of the week in year.
timeZone
TimeZoneInfoTarget time zone.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
- ZonedWeek?
New ZonedWeek instance or null when
weekOfYear
is less than 1 or greater than the maximum week number in the specifiedyear
.
TryCreateLocal(int, int, IsoDayOfWeek)
[Pure]
public static ZonedWeek? TryCreateLocal(int year, int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
year
intYear component of the week.
weekOfYear
intNumber of the week in year.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
- ZonedWeek?
New ZonedWeek instance or null when
weekOfYear
is less than 1 or greater than the maximum week number in the specifiedyear
.
TryCreateUtc(int, int, IsoDayOfWeek)
[Pure]
public static ZonedWeek? TryCreateUtc(int year, int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)
Parameters
year
intYear component of the week.
weekOfYear
intNumber of the week in year.
weekStart
IsoDayOfWeekFirst day of the week. Equal to Monday by default.
Returns
- ZonedWeek?
New ZonedWeek instance or null when
weekOfYear
is less than 1 or greater than the maximum week number in the specifiedyear
.
TrySetWeekOfYear(int)
Attempts to create a new ZonedWeek instance by setting the WeekOfYear component in this instance.
[Pure]
public ZonedWeek? TrySetWeekOfYear(int week)
Parameters
week
intWeek of year to set.
Returns
TrySetWeekStart(IsoDayOfWeek)
Attempts to create a new ZonedWeek instance by setting new first day of the week in this instance.
[Pure]
public ZonedWeek? TrySetWeekStart(IsoDayOfWeek weekStart)
Parameters
weekStart
IsoDayOfWeekFirst day of the week to set.
Returns
- ZonedWeek?
New ZonedWeek instance or null when
weekStart
results in the creation of an invalid week.
Operators
operator +(ZonedWeek, Period)
Creates a new ZonedWeek instance by adding a
and b
together.
[Pure]
public static ZonedWeek operator +(ZonedWeek a, Period b)
Parameters
Returns
operator ==(ZonedWeek, ZonedWeek)
Checks if a
is equal to b
.
[Pure]
public static bool operator ==(ZonedWeek a, ZonedWeek b)
Parameters
Returns
- bool
true when operands are equal, otherwise false.
operator >(ZonedWeek, ZonedWeek)
Checks if a
is greater than b
.
[Pure]
public static bool operator >(ZonedWeek a, ZonedWeek b)
Parameters
Returns
- bool
true when
a
is greater thanb
, otherwise false.
operator >=(ZonedWeek, ZonedWeek)
Checks if a
is greater than or equal to b
.
[Pure]
public static bool operator >=(ZonedWeek a, ZonedWeek b)
Parameters
Returns
- bool
true when
a
is greater than or equal tob
, otherwise false.
operator !=(ZonedWeek, ZonedWeek)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(ZonedWeek a, ZonedWeek b)
Parameters
Returns
- bool
true when operands are not equal, otherwise false.
operator <(ZonedWeek, ZonedWeek)
Checks if a
is less than b
.
[Pure]
public static bool operator <(ZonedWeek a, ZonedWeek b)
Parameters
Returns
- bool
true when
a
is less thanb
, otherwise false.
operator <=(ZonedWeek, ZonedWeek)
Checks if a
is less than or equal to b
.
[Pure]
public static bool operator <=(ZonedWeek a, ZonedWeek b)
Parameters
Returns
- bool
true when
a
is less than or equal tob
, otherwise false.
operator -(ZonedWeek, Period)
Creates a new ZonedWeek instance by subtracting b
from a
.
[Pure]
public static ZonedWeek operator -(ZonedWeek a, Period b)