Table of Contents

Struct ZonedWeek

Namespace
LfrlAnvil.Chrono
Assembly
LfrlAnvil.Chrono.dll

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

Duration

End

End of this week.

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

Start

Start of this week.

public ZonedDateTime Start { get; }

Property Value

ZonedDateTime

TimeZone

Time zone of this week.

public TimeZoneInfo TimeZone { get; }

Property Value

TimeZoneInfo

WeekOfYear

Week of year component.

public int WeekOfYear { get; }

Property Value

int

Year

Year component.

public int Year { get; }

Property Value

int

Methods

Add(Period)

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

[Pure]
public ZonedWeek Add(Period value)

Parameters

value Period

Period to add.

Returns

ZonedWeek

New ZonedWeek instance.

AddWeeks(int)

Creates a new ZonedWeek instance by adding provided number of weeks to this instance.

[Pure]
public ZonedWeek AddWeeks(int weeks)

Parameters

weeks int

Number of weeks to add.

Returns

ZonedWeek

New ZonedWeek instance.

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 ZonedWeek

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

[Pure]
public bool Contains(ZonedDateTime dateTime)

Parameters

dateTime ZonedDateTime

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

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

Date time contained by the result.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

Create(ZonedDay, IsoDayOfWeek)

Creates a new ZonedWeek instance.

[Pure]
public static ZonedWeek Create(ZonedDay day, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

day ZonedDay

Day contained by the result.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

Create(DateTime, TimeZoneInfo, IsoDayOfWeek)

Creates a new ZonedWeek instance.

[Pure]
public static ZonedWeek Create(DateTime dateTime, TimeZoneInfo timeZone, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

dateTime DateTime

Date time contained by the result.

timeZone TimeZoneInfo

Target time zone.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

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 int

Year component of the week.

weekOfYear int

Number of the week in year.

timeZone TimeZoneInfo

Target time zone.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

Exceptions

ArgumentOutOfRangeException

When weekOfYear is less than 1 or greater than the maximum week number in the specified year.

CreateLocal(DateTime, IsoDayOfWeek)

Creates a new ZonedWeek instance in Local time zone.

[Pure]
public static ZonedWeek CreateLocal(DateTime localDateTime, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

localDateTime DateTime

Date time contained by the result.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

CreateLocal(int, int, IsoDayOfWeek)

Creates a new ZonedWeek instance in Local time zone.

[Pure]
public static ZonedWeek CreateLocal(int year, int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

year int

Year component of the week.

weekOfYear int

Number of the week in year.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

Exceptions

ArgumentOutOfRangeException

When weekOfYear is less than 1 or greater than the maximum week number in the specified year.

CreateUtc(Timestamp, IsoDayOfWeek)

Creates a new ZonedWeek instance in Utc time zone.

[Pure]
public static ZonedWeek CreateUtc(Timestamp timestamp, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

timestamp Timestamp

Timestamp contained by the result.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

CreateUtc(DateTime, IsoDayOfWeek)

Creates a new ZonedWeek instance in Utc time zone.

[Pure]
public static ZonedWeek CreateUtc(DateTime utcDateTime, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

utcDateTime DateTime

Date time contained by the result.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

CreateUtc(int, int, IsoDayOfWeek)

Creates a new ZonedWeek instance in Utc time zone.

[Pure]
public static ZonedWeek CreateUtc(int year, int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

year int

Year component of the week.

weekOfYear int

Number of the week in year.

weekStart IsoDayOfWeek

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

Returns

ZonedWeek

New ZonedWeek instance.

Exceptions

ArgumentOutOfRangeException

When weekOfYear is less than 1 or greater than the maximum week number in the specified year.

Equals(ZonedWeek)

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

[Pure]
public bool Equals(ZonedWeek other)

Parameters

other ZonedWeek

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 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 IsoDayOfWeek

Day of this week to get.

Returns

ZonedDay

New ZonedDay instance.

GetFriday()

Creates a new ZonedDay instance that represents Friday of this week.

[Pure]
public ZonedDay GetFriday()

Returns

ZonedDay

New ZonedDay instance.

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 ZonedWeek

Start week.

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.

GetMonday()

Creates a new ZonedDay instance that represents Monday of this week.

[Pure]
public ZonedDay GetMonday()

Returns

ZonedDay

New ZonedDay instance.

GetNext()

Creates a new ZonedWeek instance by calculating the next week.

[Pure]
public ZonedWeek GetNext()

Returns

ZonedWeek

New ZonedWeek instance.

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 ZonedWeek

Start week.

units PeriodUnits

PeriodUnits to include in the calculated difference.

Returns

Period

New Period instance.

GetPrevious()

Creates a new ZonedWeek instance by calculating the previous week.

[Pure]
public ZonedWeek GetPrevious()

Returns

ZonedWeek

New ZonedWeek instance.

GetSaturday()

Creates a new ZonedDay instance that represents Saturday of this week.

[Pure]
public ZonedDay GetSaturday()

Returns

ZonedDay

New ZonedDay instance.

GetSunday()

Creates a new ZonedDay instance that represents Sunday of this week.

[Pure]
public ZonedDay GetSunday()

Returns

ZonedDay

New ZonedDay instance.

GetThursday()

Creates a new ZonedDay instance that represents Thursday of this week.

[Pure]
public ZonedDay GetThursday()

Returns

ZonedDay

New ZonedDay instance.

GetTuesday()

Creates a new ZonedDay instance that represents Tuesday of this week.

[Pure]
public ZonedDay GetTuesday()

Returns

ZonedDay

New ZonedDay instance.

GetWednesday()

Creates a new ZonedDay instance that represents Wednesday of this week.

[Pure]
public ZonedDay GetWednesday()

Returns

ZonedDay

New ZonedDay instance.

GetYear()

Creates a new ZonedYear instance that contains this instance.

[Pure]
public ZonedYear GetYear()

Returns

ZonedYear

New ZonedYear instance.

SetWeekOfYear(int)

Creates a new ZonedWeek instance by setting the WeekOfYear component in this instance.

[Pure]
public ZonedWeek SetWeekOfYear(int week)

Parameters

week int

Week of year to set.

Returns

ZonedWeek

New ZonedWeek instance.

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 IsoDayOfWeek

First day of the week to set.

Returns

ZonedWeek

New ZonedWeek instance.

Exceptions

ArgumentOutOfRangeException

When weekStart results in the creation of an invalid week.

SetYear(int)

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

[Pure]
public ZonedWeek SetYear(int year)

Parameters

year int

Year to set.

Returns

ZonedWeek

New ZonedWeek instance.

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

value Period

Period to subtract.

Returns

ZonedWeek

New ZonedWeek instance.

SubtractWeeks(int)

Creates a new ZonedWeek instance by subtracting provided number of weeks from this instance.

[Pure]
public ZonedWeek SubtractWeeks(int weeks)

Parameters

weeks int

Number of weeks to subtract.

Returns

ZonedWeek

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

[Pure]
public ZonedWeek ToLocalTimeZone()

Returns

ZonedWeek

New ZonedWeek instance.

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 TimeZoneInfo

Target time zone.

Returns

ZonedWeek

New ZonedWeek instance.

ToUtcTimeZone()

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

[Pure]
public ZonedWeek ToUtcTimeZone()

Returns

ZonedWeek

New ZonedWeek instance.

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 int

Year component of the week.

weekOfYear int

Number of the week in year.

timeZone TimeZoneInfo

Target time zone.

weekStart IsoDayOfWeek

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

TryCreateLocal(int, int, IsoDayOfWeek)

Attempts to create a new ZonedWeek instance in Local time zone.

[Pure]
public static ZonedWeek? TryCreateLocal(int year, int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

year int

Year component of the week.

weekOfYear int

Number of the week in year.

weekStart IsoDayOfWeek

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

TryCreateUtc(int, int, IsoDayOfWeek)

Attempts to create a new ZonedWeek instance in Utc time zone.

[Pure]
public static ZonedWeek? TryCreateUtc(int year, int weekOfYear, IsoDayOfWeek weekStart = IsoDayOfWeek.Monday)

Parameters

year int

Year component of the week.

weekOfYear int

Number of the week in year.

weekStart IsoDayOfWeek

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

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 int

Week of year to set.

Returns

ZonedWeek?

New ZonedWeek instance or null when week is not valid.

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 IsoDayOfWeek

First 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

a ZonedWeek

First operand.

b Period

Second operand.

Returns

ZonedWeek

New ZonedWeek instance.

operator ==(ZonedWeek, ZonedWeek)

Checks if a is equal to b.

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

Parameters

a ZonedWeek

First operand.

b ZonedWeek

Second operand.

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

a ZonedWeek

First operand.

b ZonedWeek

Second operand.

Returns

bool

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

a ZonedWeek

First operand.

b ZonedWeek

Second operand.

Returns

bool

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

operator !=(ZonedWeek, ZonedWeek)

Checks if a is not equal to b.

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

Parameters

a ZonedWeek

First operand.

b ZonedWeek

Second operand.

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

a ZonedWeek

First operand.

b ZonedWeek

Second operand.

Returns

bool

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

a ZonedWeek

First operand.

b ZonedWeek

Second operand.

Returns

bool

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

operator -(ZonedWeek, Period)

Creates a new ZonedWeek instance by subtracting b from a.

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

Parameters

a ZonedWeek

First operand.

b Period

Second operand.

Returns

ZonedWeek

New ZonedWeek instance.