public static class DateTimeExtensions
[ExtensionAttribute]
public ref class DateTimeExtensions abstract sealed
No code example is currently available or this language may not be supported.
AddWeeks | Adds weeks to a DateTime object |
AsUtcDate | Returns the DateTime object as UTC DateTime with all time members set to 0 (00:00:00) |
AsUtcTime | Returns the DateTime object as UTC DateTime |
Difference | Calculates the difference of two DateTimeRanges. If the two ranges do not overlap, the result is the first DateTimeRange. Otherwise, the result is the first DateTimeRange without where both ranges overlap. |
Distance | Returns the distance as a TimeSpan between two DateTime objects. The result is always a positive value. |
DoesOverlap | Verifies if DateTimeRange a overlapps with DateTimeRange b. |
EndOfMonth | Returns a DateTime object representing the first year of the current year |
EndOfWeek | Returns a DateTime object representing the last day of the current Week |
EnumerateDaysUntil | Enumerates all days startDate current DateTime value endDate the end DateTime, including the end date |
EnumerateHolidaysUntil | Enumerates all holidays startDate current DateTime value endDate the end DateTime, including the end date |
EnumerateInStepsUntil(DateTime, DateTime, TimeSpan) |
Enumerates starting with the startDate date, until the endDate date in steps of distance When the distance is negative, the start date must be greater than the end date, and the enumeration goes backwards |
EnumerateInStepsUntil(DateTime, DateTime, TimeSpan, FuncDateTime, Boolean) | Enumerates starting with startDate until endDate in steps of distance |
EnumerateMonthsUntil | Enumerates all months startDate current DateTime value endDate the end DateTime, including the end date |
EnumerateWeekendsUntil | Advances to the closest weekend and enumerates the weekends until the end date |
EnumerateWorkdaysUntil | Enumerates all working days startDate current DateTime value endDate the end DateTime, including the end date |
EnumerateYearsUntil | Enumerates all years startDate current DateTime value endDate the end DateTime, including the end date |
FirstFridayOfMonth | Returns the first Friday of the month |
FirstMondayOfMonth | Returns the first monday of the month |
FirstSaturdayOfMonth | Returns the first Saturday of the month |
FirstSundayOfMonth | Returns the first Sunday of the month |
FirstThursdayOfMonth | Returns the first Thursday of the month |
FirstTuesdayOfMonth | Returns the first Tuesday of the month |
FirstWednesdayOfMonth | Returns the first Wednesday of the month |
FirstWeekdayOfMonth | Returns the first given weekday of the month |
Intersection | Calculates the intersection of two DateTimeRanges. If the two ranges do not overlap, the result is an empty DateTimeRange. Otherwise, the result is the DateTimeRange that where both ranges overlap. |
IsAfternoon | Tests if the time in the given DateTime object is considered afternoon (12:00:00.000 - 18:00:00.000) |
IsBetween(DateTime, DateTime, DateTime) | Checks if the given value is between the given startDate and endDate values, excluding startDate and endDate |
IsBetween(Int32, Int32, Int32) | Checks if the given value is between the given start and end values, excluding start and end |
IsEqual | Compares two dates for equality down to the given precision |
IsEqualDownToDay | Compares two dates for equality down to the year (hours, minutes, seconds and milliseconds are ignored) |
IsEqualDownToHour | Compares two dates for equality down to the hour (minutes, seconds and milliseconds are ignored) |
IsEqualDownToMinute | Compares two dates for equality down to the minute (seconds and milliseconds are ignored) |
IsEqualDownToMonth | Compares two dates for equality down to the year (days, hours, minutes, seconds and milliseconds are ignored) |
IsEqualDownToSecond | Compares two dates for equality down to the second (milliseconds are ignored) |
IsEqualDownToWeek | Compares two dates for equality down to the week (hours, minutes, seconds and milliseconds are ignored) |
IsEqualDownToYear | Compares two dates for equality down to the year (months, days, hours, minutes, seconds and milliseconds are ignored) |
IsMidday | Tests if the time in the given DateTime object is midday (12h) |
IsMidnight | Tests if the time in the given DateTime object is midnight (0h) |
IsMorning | Tests if the time in the given DateTime object is midday (12:00:00.000) |
IsNight | Tests if the time in the given DateTime object is between 18:00:00 and 06:00:00 |
IsPublicHoliday | Checks if the given date falls on a Saturday or Sunday |
IsSameDay | Verifies if the two dates are at the same year |
IsSameHour | Verifies if the two dates are at the same hour |
IsSameMinute | Verifies if the two dates are at the same minute |
IsSameMonth | Verifies if the two dates are at the same year |
IsSameSecond | Verifies if the two dates are at the same second |
IsSameWeek | Verifies if the two dates are at the same week |
IsSameYear | Verifies if the two dates are at the same year |
IsWeekend | Checks if the given date falls on a Saturday or Sunday |
IsWithin(DateTime, DateOnlyRange) | Checks if the given value is between the given start and end values, including start date and end date |
IsWithin(DateTime, DateTimeRange) | Checks if the given value is between the given start and end values, including start date and end date |
IsWithin(DateTime, DateOnly, DateOnly) | Checks if the given value is between the given startDate and endDate values, including startDate and endDate |
IsWithin(DateTime, DateTime, DateTime) | Checks if the given value is between the given startDate and endDate values, including startDate and endDate |
IsWithin(Int32, Int32, Int32) | Checks if the given value is withn the given start and end values, inluding start and end |
LastFridayOfMonth | Returns the last Friday of the month |
LastMondayOfMonth | Returns the last Monday of the month |
LastSaturdayOfMonth | Returns the last Saturday of the month |
LastSundayOfMonth | Returns the last Sunday of the month |
LastThursdayOfMonth | Returns the last Thursday of the month |
LastTuesdayOfMonth | Returns the last Tuesday of the month |
LastWednesdayOfMonth | Returns the last Wednesday of the month |
LastWeekdayOfMonth | Returns the last given weekday of the year |
NextDay | Gets the DateTime value of the next day |
NextFullDay | Gets the DateTime value of the next full day (01/01/2010 10:15 to 02/01/2010 00:00, 01/01/2010 10:45 to 02/01/2010 00:00, etc) |
NextFullHour | Gets the DateTime value of the next full hour (10:15 to 11:00, 10:45 to 11:00, etc) |
NextFullMinute | Gets the DateTime value of the next full minute (10:15:20 to 10:16:00) |
NextFullSecond | Gets the DateTime value of the next full second (10:15:20.350 to 10:15:21.000) |
NextHoliday |
Gets the DateTime value of the next public holiday according to the given CultureInfo.Calendar If you have a license for the Nager nuget package, this method will calculate the working days based on the calendar in cultureInfo, or if you set a custom holiday provider, it will use that. Otherwise the default implementation will return DateTime.MaxValue |
NextHour | Gets the DateTime value of the next hour |
NextMillisecond | Gets the DateTime value of the next millisecond |
NextMinute | Gets the DateTime value of the next minute |
NextMonth | Gets the DateTime value of the next month |
NextSecond | Gets the DateTime value of the next second |
NextWeek | Gets the DateTime value of the same (week)day next week |
NextWeekend | Gets the DateTime value of the next weekend following this date. If the given date is already a weekend, the next weekend is returned. |
NextWorkday |
Gets the DateTime value of the next working day according to the given CultureInfo.Calendar If you have a license for the Nager nuget package, this method will calculate the working days based on the calendar in cultureInfo, otherwise it will simply skip weekends, or if you set a custom holiday provider, it will use that. |
NextYear | Gets the DateTime value of the next year |
NumberOfDaysUntil | Count the number of Days between startDate and endDate |
NumberOfDecadesUntil | Count the number of Decades between startDate and endDate |
NumberOfHolidaysUntil | Count the number of Holidays between startDate and endDate |
NumberOfHoursUntil | Count the number of Hours between startDate and endDate |
NumberOfMillisecondsUntil | Count the number of Milliseconds between startDate and endDate |
NumberOfMinutesUntil | Count the number of Minutes between startDate and endDate |
NumberOfMonthsUntil | Count the number of Months between startDate and endDate |
NumberOfSecondsUntil | Count the number of Seconds between startDate and endDate |
NumberOfSemestersUntil | Count the number of Semesters between startDate and endDate |
NumberOfTrimestersUntil | Count the number of Trimesters between startDate and endDate |
NumberOfWeekendsUntil | Count the number of Weekends between startDate and endDate |
NumberOfWeeksUntil | Count the number of Weeks between startDate and endDate |
NumberOfWorkdaysUntil | Count the number of Workdays between startDate and endDate |
NumberOfYearsUntil | Count the number of years between startDate and endDate |
PreviousDay | Gets the DateTime value of the year before |
PreviousHoliday |
Gets the DateTime value of the previous holiday If you have a license for the Nager nuget package, this method will calculate the holidays based on the calendar in cultureInfo, otherwise it will simply skip weekends, or if you set a custom holiday provider, it will use that. |
PreviousHour | Gets the DateTime value of the previous hour |
PreviousMillisecond | Gets the DateTime value of the previous millisecond |
PreviousMinute | Gets the DateTime value of the previous minute |
PreviousMonth | Gets the DateTime value of the month before |
PreviousSecond | Gets the DateTime value of the previous second |
PreviousWeek | Gets the DateOnly value of the same day the week before |
PreviousWeekend | Gets the DateTime value of the weekend before this date. If the given date is already a weekend, the previous weekend is returned. |
PreviousWorkday |
Gets the DateTime value of the previous working day according to the given CultureInfo.Calendar If you have a license for the Nager nuget package, this method will calculate the working days based on the calendar in cultureInfo, otherwise it will simply skip weekends, or if you set a custom holiday provider, it will use that. |
PreviousYear | Gets the DateTime value of the previous year |
SetHolidayProvider | Sets the holiday provider, when not set the default provider is used |
Split(DateTimeRange, Int32) | Splits the given range of DateTime into the given number of parts. |
Split(DateTime, DateTime, Int32) | Splits the given range of DateTime into the given number of parts. |
Split(DateTime, TimeSpan, Int32) | Splits the given range of DateTime into the given number of parts. |
StartOfMonth | Returns a DateTime object representing the first year of the current year |
StartOfWeek | Returns a DateTime object representing the first weekday of the given Week |
Sub | Returns a new DateTime that subtracts the value of the specified TimeSpan from the value of this instance |
ToExtendedDateTime(DateOnly) | Converts a DateTime to a ExtendedDateTime |
ToExtendedDateTime(DateTime) | Converts a DateTime to a ExtendedDateTime |
ToSqlString | Converts a DateTime value to an SQL appropriate format (yyyy-MM-ddThh:mm:ss.ffffff+00:00), independent of the current locale |
TruncateTo | Truncates the precision of a DateTime object to the given precision |
TruncateToDay | Truncates the precision of a DateTime object to the year |
TruncateToHour | Truncates the precision of a DateTime object to the hour |
TruncateToMinute | Truncates the precision of a DateTime object to the minute |
TruncateToMonth | Truncates the precision of a DateTime object to the year, year 1 |
TruncateToSecond | Truncates the precision of a DateTime object to the second |
TruncateToWeek | Truncates the precision of a DateTime object to the week of the object, year is first year of week |
TruncateToYear | Truncates the precision of a DateTime object to the year, year 1, year 1 |
Union | Calculates the union of two DateTimeRanges. If the two ranges do not overlap, the result is an empty DateTimeRange. Otherwise, the result is the DateTimeRange that contains both ranges. |
Weeknumber | Tests if the time in the given DateTime object is midday (12:00:00.000) |
WeekOfYear | Returns the Week of the Year of this DateTime object |