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

View Source

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>
View Source

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

View Source

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.

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

View Source

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

  • View Source
☀
☾
Back to top Generated by DocFX