Show / Hide Table of Contents

Class DatePeriodExtensions

DatePeriod extension methods

Inheritance
object
DatePeriodExtensions
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: PayrollEngine.Client.Scripting
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public static class DatePeriodExtensions

Methods

Days(DatePeriod)

Get period days

Declaration
public static List<DateTime> Days(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
List<DateTime>

GetWorkingDaysCount(DatePeriod, IEnumerable<DayOfWeek>)

Calculate the count of working days

Declaration
public static int GetWorkingDaysCount(this DatePeriod period, IEnumerable<DayOfWeek> days)
Parameters
Type Name Description
DatePeriod period
IEnumerable<DayOfWeek> days

Available days

Returns
Type Description
int

The number of working days

HasOverlapping(IEnumerable<DatePeriod>)

Test if any period is overlapping another period

Declaration
public static bool HasOverlapping(this IEnumerable<DatePeriod> datePeriods)
Parameters
Type Name Description
IEnumerable<DatePeriod> datePeriods
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(DatePeriod, DatePeriod)

Get the intersection of a date period with this period

Declaration
public static DatePeriod Intersect(this DatePeriod period, DatePeriod intersectPeriod)
Parameters
Type Name Description
DatePeriod period
DatePeriod intersectPeriod

The period to intersect

Returns
Type Description
DatePeriod

The intersecting date period, null if no intersection is present

Intersections(IEnumerable<DatePeriod>, DatePeriod)

Get all intersections of a date period with any date period

Declaration
public static List<DatePeriod> Intersections(this IEnumerable<DatePeriod> datePeriods, DatePeriod intersectPeriod)
Parameters
Type Name Description
IEnumerable<DatePeriod> datePeriods
DatePeriod intersectPeriod

The period to intersect

Returns
Type Description
List<DatePeriod>

List of intersecting date periods

IsAfter(DatePeriod, DatePeriod)

Test if a specific time period is after this period

Declaration
public static bool IsAfter(this DatePeriod period, DatePeriod testPeriod)
Parameters
Type Name Description
DatePeriod period
DatePeriod testPeriod

The period to test

Returns
Type Description
bool

True, if the period is after this period

IsAfter(DatePeriod, DateTime)

Test if a specific time moment is after this period

Declaration
public static bool IsAfter(this DatePeriod period, DateTime testMoment)
Parameters
Type Name Description
DatePeriod period
DateTime testMoment

The moment to test

Returns
Type Description
bool

True, if the moment is after this period

IsBefore(DatePeriod, DatePeriod)

Test if a specific time period is before this period

Declaration
public static bool IsBefore(this DatePeriod period, DatePeriod testPeriod)
Parameters
Type Name Description
DatePeriod period
DatePeriod testPeriod

The period to test

Returns
Type Description
bool

True, if the period is before this period

IsBefore(DatePeriod, DateTime)

Test if a specific time moment is before this period

Declaration
public static bool IsBefore(this DatePeriod period, DateTime testMoment)
Parameters
Type Name Description
DatePeriod period
DateTime testMoment

The moment to test

Returns
Type Description
bool

True, if the moment is before this period

IsEndDay(DatePeriod, DateTime)

Test if a date is the period end day

Declaration
public static bool IsEndDay(this DatePeriod period, DateTime test)
Parameters
Type Name Description
DatePeriod period
DateTime test

The date to test

Returns
Type Description
bool

True, if the test date is the period end day

IsEndDayOfWeek(DatePeriod, DayOfWeek)

Test if the period end is on a specific weekday

Declaration
public static bool IsEndDayOfWeek(this DatePeriod period, DayOfWeek testDay)
Parameters
Type Name Description
DatePeriod period
DayOfWeek testDay

The weekday to test

Returns
Type Description
bool

True, if the period end day matches the weekday

IsEndFriday(DatePeriod)

Test if the period end is a friday

Declaration
public static bool IsEndFriday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period end day is a friday

IsEndMonday(DatePeriod)

Test if the period end is a monday

Declaration
public static bool IsEndMonday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period end day is a monday

IsEndSaturday(DatePeriod)

Test if the period end is a saturday

Declaration
public static bool IsEndSaturday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period end day is a saturday

IsEndSunday(DatePeriod)

Test if the period end is a sunday

Declaration
public static bool IsEndSunday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period end day is a sunday

IsEndThursday(DatePeriod)

Test if the period end is a thursday

Declaration
public static bool IsEndThursday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period end day is a thursday

IsEndTuesday(DatePeriod)

Test if the period end is a tuesday

Declaration
public static bool IsEndTuesday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period end day is a tuesday

IsEndWednesday(DatePeriod)

Test if the period end is a wednesday

Declaration
public static bool IsEndWednesday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period end day is a Wednesday

IsFirstDay(DatePeriod, DateTime)

Test if a specific time moment is the first day of a period

Declaration
public static bool IsFirstDay(this DatePeriod period, DateTime test)
Parameters
Type Name Description
DatePeriod period
DateTime test

The moment to test

Returns
Type Description
bool

True if the test day is the first period day

IsLastDay(DatePeriod, DateTime)

Test if a specific time moment is the last day of a period

Declaration
public static bool IsLastDay(this DatePeriod period, DateTime test)
Parameters
Type Name Description
DatePeriod period
DateTime test

The moment to test

Returns
Type Description
bool

True if the test day is the last period day

IsOverlapping(DatePeriod, DatePeriod)

Test if period is overlapping this period

Declaration
public static bool IsOverlapping(this DatePeriod period, DatePeriod testPeriod)
Parameters
Type Name Description
DatePeriod period
DatePeriod testPeriod

The period to test

Returns
Type Description
bool

True, if the period is overlapping this period

IsStartDay(DatePeriod, DateTime)

Test if a date is the period start day

Declaration
public static bool IsStartDay(this DatePeriod period, DateTime test)
Parameters
Type Name Description
DatePeriod period
DateTime test

The date to test

Returns
Type Description
bool

True, if the test date is the period start day

IsStartDayOfWeek(DatePeriod, DayOfWeek)

Test if the period start is on a specific weekday

Declaration
public static bool IsStartDayOfWeek(this DatePeriod period, DayOfWeek testDay)
Parameters
Type Name Description
DatePeriod period
DayOfWeek testDay

The weekday to test

Returns
Type Description
bool

True, if the period start day matches the weekday

IsStartFriday(DatePeriod)

Test if the period start is a friday

Declaration
public static bool IsStartFriday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period start day is a friday

IsStartMonday(DatePeriod)

Test if the period start is a monday

Declaration
public static bool IsStartMonday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period start day is a monday

IsStartSaturday(DatePeriod)

Test if the period start is a saturday

Declaration
public static bool IsStartSaturday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period start day is a saturday

IsStartSunday(DatePeriod)

Test if the period start is a sunday

Declaration
public static bool IsStartSunday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period start day is a sunday

IsStartThursday(DatePeriod)

Test if the period start is a thursday

Declaration
public static bool IsStartThursday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period start day is a thursday

IsStartTuesday(DatePeriod)

Test if the period start is a tuesday

Declaration
public static bool IsStartTuesday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period start day is a tuesday

IsStartWednesday(DatePeriod)

Test if the period start is a wednesday

Declaration
public static bool IsStartWednesday(this DatePeriod period)
Parameters
Type Name Description
DatePeriod period
Returns
Type Description
bool

True, if the period start day is a Wednesday

IsWithin(DatePeriod, DatePeriod)

Test if a specific time period is within the period, including open periods

Declaration
public static bool IsWithin(this DatePeriod period, DatePeriod testPeriod)
Parameters
Type Name Description
DatePeriod period
DatePeriod testPeriod

The period to test

Returns
Type Description
bool

True, if the test period is within this period

IsWithin(DatePeriod, DateTime)

Test if a specific time moment is within the period, including open periods

Declaration
public static bool IsWithin(this DatePeriod period, DateTime testMoment)
Parameters
Type Name Description
DatePeriod period
DateTime testMoment

The moment to test

Returns
Type Description
bool

True, if the moment is within this period

IsWithinAny(IEnumerable<DatePeriod>, DatePeriod)

Test if a specific time period is within any date period

Declaration
public static bool IsWithinAny(this IEnumerable<DatePeriod> datePeriods, DatePeriod testPeriod)
Parameters
Type Name Description
IEnumerable<DatePeriod> datePeriods
DatePeriod testPeriod

The period to test

Returns
Type Description
bool

True, if the test period is within this period

IsWithinAny(IEnumerable<DatePeriod>, DateTime)

Test if a specific time moment is within any date period

Declaration
public static bool IsWithinAny(this IEnumerable<DatePeriod> datePeriods, DateTime testMoment)
Parameters
Type Name Description
IEnumerable<DatePeriod> datePeriods
DateTime testMoment

The moment to test

Returns
Type Description
bool

True, if the moment is within this period

IsWithinOrAfter(DatePeriod, DateTime)

Test if a specific time moment is within or after the period, including open periods

Declaration
public static bool IsWithinOrAfter(this DatePeriod period, DateTime testMoment)
Parameters
Type Name Description
DatePeriod period
DateTime testMoment

The moment to test

Returns
Type Description
bool

True, if the moment is within or after this period

IsWithinOrBefore(DatePeriod, DateTime)

Test if a specific time moment is within or before the period, including open periods

Declaration
public static bool IsWithinOrBefore(this DatePeriod period, DateTime testMoment)
Parameters
Type Name Description
DatePeriod period
DateTime testMoment

The moment to test

Returns
Type Description
bool

True, if the moment is within or before this period

Limits(IEnumerable<DatePeriod>)

Get limits period, from the earliest start to the latest end

Declaration
public static DatePeriod Limits(this IEnumerable<DatePeriod> datePeriods)
Parameters
Type Name Description
IEnumerable<DatePeriod> datePeriods
Returns
Type Description
DatePeriod

Date period including all date periods, an anytime period for empty collections

Split(DatePeriod, List<DateTime>)

Split date period by splitting dates

Declaration
public static List<DatePeriod> Split(this DatePeriod period, List<DateTime> splitMoments)
Parameters
Type Name Description
DatePeriod period
List<DateTime> splitMoments

The moments used to split

Returns
Type Description
List<DatePeriod>

The splitting periods

TotalDuration(IEnumerable<DatePeriod>)

Total duration of all date periods

Declaration
public static TimeSpan TotalDuration(this IEnumerable<DatePeriod> datePeriods)
Parameters
Type Name Description
IEnumerable<DatePeriod> datePeriods
Returns
Type Description
TimeSpan

Accumulated total duration

☀
☾
Back to top Generated by DocFX