Class DatePeriod
An immutable date period between the start and end date
Inherited Members
Namespace: PayrollEngine.Client.Scripting
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public sealed class DatePeriod
Constructors
DatePeriod()
Create a full period
Declaration
public DatePeriod()
DatePeriod(DateTime, DateTime)
Create a period from start to end
Declaration
public DatePeriod(DateTime start, DateTime end)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | start | |
| DateTime | end |
DatePeriod(DateTime?, DateTime?)
Create a period from conditional start to conditional end
Declaration
public DatePeriod(DateTime? start, DateTime? end)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime? | start | |
| DateTime? | end |
Properties
Duration
The period duration, only for closed period
Declaration
[JsonIgnore]
public TimeSpan Duration { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
End
The period end
Declaration
public DateTime End { get; init; }
Property Value
| Type | Description |
|---|---|
| DateTime |
HasEnd
Check for end
Declaration
[JsonIgnore]
public bool HasEnd { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasStart
Check for start
Declaration
public bool HasStart { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsAnytime
Test for anytime period (without start and end)
Declaration
[JsonIgnore]
public bool IsAnytime { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsEmpty
Test if period is empty
Declaration
[JsonIgnore]
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsMoment
Test if start and end are equal
Declaration
[JsonIgnore]
public bool IsMoment { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsOpen
Test for open period (no start or no end)
Declaration
[JsonIgnore]
public bool IsOpen { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsUtc
Test if start and end are UTC
Declaration
[JsonIgnore]
public bool IsUtc { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsWithinDay
Test if the period is within a day
Declaration
[JsonIgnore]
public bool IsWithinDay { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsWithinHour
Test if the period is within an hour
Declaration
[JsonIgnore]
public bool IsWithinHour { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsWithinMonth
Test if the period is within a month
Declaration
[JsonIgnore]
public bool IsWithinMonth { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsWithinYear
Test if the period is within a year
Declaration
[JsonIgnore]
public bool IsWithinYear { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Start
The period start
Declaration
public DateTime Start { get; init; }
Property Value
| Type | Description |
|---|---|
| DateTime |
TotalDays
Gets the value of the TimeSpan between start and end expressed in whole and fractional days
Declaration
[JsonIgnore]
public double TotalDays { get; }
Property Value
| Type | Description |
|---|---|
| double | The total number of days represented by this instance |
TotalHours
Gets the value of the TimeSpan between start and end expressed in whole and fractional hours
Declaration
[JsonIgnore]
public double TotalHours { get; }
Property Value
| Type | Description |
|---|---|
| double | The total number of hours represented by this instance |
TotalMinutes
Gets the value of the TimeSpan between start and end expressed in whole and fractional minutes
Declaration
[JsonIgnore]
public double TotalMinutes { get; }
Property Value
| Type | Description |
|---|---|
| double | The minutes number of hours represented by this instance |
Methods
Equals(object)
Determines whether the specified object is equal to this instance
Declaration
public override bool Equals(object source)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The object to compare with the current object |
Returns
| Type | Description |
|---|---|
| bool | True if the specified object is equal to this instance |
Overrides
FromEnd(TimeSpan, DateTime)
Create period from end date and duration
Declaration
public static DatePeriod FromEnd(TimeSpan duration, DateTime end)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | Period duration |
| DateTime | end | Period end |
Returns
| Type | Description |
|---|---|
| DatePeriod |
FromStart(DateTime, TimeSpan)
Create period from start date and duration
Declaration
public static DatePeriod FromStart(DateTime start, TimeSpan duration)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | start | Period start |
| TimeSpan | duration | Period duration |
Returns
| Type | Description |
|---|---|
| DatePeriod |
GetHashCode()
Returns a hash code for this instance
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table |
Overrides
ToString()
Returns a string that represents this instance
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string that represents this instance |
Overrides
Operators
operator ==(DatePeriod, DatePeriod)
Compare two date periods for equal values
Declaration
public static bool operator ==(DatePeriod left, DatePeriod right)
Parameters
| Type | Name | Description |
|---|---|---|
| DatePeriod | left | The left period to compare |
| DatePeriod | right | The right period to compare |
Returns
| Type | Description |
|---|---|
| bool | True if the periods are equal |
operator !=(DatePeriod, DatePeriod)
Compare two date periods for different values
Declaration
public static bool operator !=(DatePeriod left, DatePeriod right)
Parameters
| Type | Name | Description |
|---|---|---|
| DatePeriod | left | The left period to compare |
| DatePeriod | right | The right period to compare |
Returns
| Type | Description |
|---|---|
| bool | True if the periods are different |