Class HourPeriodExtensions
TimePeriod extension methods
Inherited Members
Namespace: PayrollEngine.Client.Scripting
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public static class HourPeriodExtensions
Methods
View SourceHasOverlapping(IEnumerable<HourPeriod>)
Test if any period is overlapping another period
Declaration
public static bool HasOverlapping(this IEnumerable<HourPeriod> timePeriods)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<HourPeriod> | timePeriods |
Returns
| Type | Description |
|---|---|
| bool | True, if the period is overlapping this period |
Remarks
Fixed: outer loop starts at 0 to include the first element in comparisons.
Intersect(HourPeriod, HourPeriod)
Get the intersection of a time period with this period
Declaration
public static HourPeriod Intersect(this HourPeriod period, HourPeriod intersectPeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| HourPeriod | intersectPeriod | The period to intersect |
Returns
| Type | Description |
|---|---|
| HourPeriod | The intersecting time period, null if no intersection is present |
IntersectHours(HourPeriod, HourPeriod)
Get the hours of intersection
Declaration
public static decimal IntersectHours(this HourPeriod period, HourPeriod intersectPeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| HourPeriod | intersectPeriod | The period to intersect |
Returns
| Type | Description |
|---|---|
| decimal | The intersecting duration in hours, 0 if no intersection is present |
Intersections(IEnumerable<HourPeriod>, HourPeriod)
Get all intersections of a time period with any time period
Declaration
public static List<HourPeriod> Intersections(this IEnumerable<HourPeriod> timePeriods, HourPeriod intersectPeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<HourPeriod> | timePeriods | |
| HourPeriod | intersectPeriod | The period to intersect |
Returns
| Type | Description |
|---|---|
| List<HourPeriod> | List of intersecting time periods |
IsAfter(HourPeriod, HourPeriod)
Test if a specific time period is after this period
Declaration
public static bool IsAfter(this HourPeriod period, HourPeriod testPeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| HourPeriod | testPeriod | The period to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the period is after this period |
IsAfter(HourPeriod, decimal)
Test if a specific time moment is after this period
Declaration
public static bool IsAfter(this HourPeriod period, decimal test)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| decimal | test | The moment to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the moment is after this period |
IsBefore(HourPeriod, HourPeriod)
Test if a specific time period is before this period
Declaration
public static bool IsBefore(this HourPeriod period, HourPeriod testPeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| HourPeriod | testPeriod | The period to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the period is before this period |
IsBefore(HourPeriod, decimal)
Test if a specific time moment is before this period
Declaration
public static bool IsBefore(this HourPeriod period, decimal test)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| decimal | test | The moment to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the moment is before this period |
IsOverlapping(HourPeriod, HourPeriod)
Test if period is overlapping this period
Declaration
public static bool IsOverlapping(this HourPeriod period, HourPeriod testPeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| HourPeriod | testPeriod | The period to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the period is overlapping this period |
IsWithin(HourPeriod, HourPeriod)
Test if a specific time period is within the period, including open periods
Declaration
public static bool IsWithin(this HourPeriod period, HourPeriod testPeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| HourPeriod | testPeriod | The period to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the test period is within this period |
IsWithin(HourPeriod, decimal)
Test if a specific time moment is within the period, including open periods
Declaration
public static bool IsWithin(this HourPeriod period, decimal test)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| decimal | test | The moment to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the moment is within this period |
IsWithinAny(IEnumerable<HourPeriod>, HourPeriod)
Test if a specific time period is within any time period
Declaration
public static bool IsWithinAny(this IEnumerable<HourPeriod> timePeriods, HourPeriod testPeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<HourPeriod> | timePeriods | |
| HourPeriod | testPeriod | The period to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the test period is within this period |
IsWithinAny(IEnumerable<HourPeriod>, decimal)
Test if a specific time moment is within any time period
Declaration
public static bool IsWithinAny(this IEnumerable<HourPeriod> timePeriods, decimal test)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<HourPeriod> | timePeriods | |
| decimal | test | The moment to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the moment is within this period |
IsWithinOrAfter(HourPeriod, decimal)
Test if a specific time moment is within or after the period, including open periods
Declaration
public static bool IsWithinOrAfter(this HourPeriod period, decimal test)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| decimal | test | The moment to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the moment is within or after this period |
IsWithinOrBefore(HourPeriod, decimal)
Test if a specific time moment is within or before the period, including open periods
Declaration
public static bool IsWithinOrBefore(this HourPeriod period, decimal test)
Parameters
| Type | Name | Description |
|---|---|---|
| HourPeriod | period | |
| decimal | test | The moment to test |
Returns
| Type | Description |
|---|---|
| bool | True, if the moment is within or before this period |
Limits(IEnumerable<HourPeriod>)
Get limits period, from the earliest start to the latest end
Declaration
public static HourPeriod Limits(this IEnumerable<HourPeriod> timePeriods)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<HourPeriod> | timePeriods |
Returns
| Type | Description |
|---|---|
| HourPeriod | Time period including all time periods, an anytime period for empty collections |
TotalDuration(IEnumerable<HourPeriod>)
Total duration of all time periods
Declaration
public static TimeSpan TotalDuration(this IEnumerable<HourPeriod> timePeriods)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<HourPeriod> | timePeriods |
Returns
| Type | Description |
|---|---|
| TimeSpan | Accumulated total duration |