Class DateTimeExtensions
- Namespace
- Wolfgang.Extensions.DateTime
- Assembly
- Wolfgang.Extensions.DateTime.dll
A collection of extension methods for DateTime
public static class DateTimeExtensions
- Inheritance
-
DateTimeExtensions
- Inherited Members
Methods
EndOfHalf(DateTime)
Returns a new DateTime that represents the last tick of the calendar half-year containing the specified DateTime. Clamps at MaxValue when the half is H2 of year 9999.
public static DateTime EndOfHalf(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the end of the half-year.
EndOfMonth(DateTime)
Returns a new DateTime that represents the last day of the month specified by the DateTime passed in.
public static DateTime EndOfMonth(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the end of the month.
EndOfQuarter(DateTime)
Returns a new DateTime that represents the last tick of the calendar quarter containing the specified DateTime. Clamps at MaxValue when the quarter is Q4 of year 9999.
public static DateTime EndOfQuarter(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the end of the quarter.
EndOfWeek(DateTime)
Returns a new DateTime that represents the last day of the week specified by the DateTime passed in using the thread's CurrentCulture FirstDayOfWeek.
public static DateTime EndOfWeek(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the end of the week.
EndOfWeek(DateTime, DayOfWeek)
Returns a new DateTime that represents the last day of the week specified by the DateTime passed in using the specified firstDayOfWeek.
public static DateTime EndOfWeek(this DateTime dateTime, DayOfWeek firstDayOfWeek)
Parameters
dateTimeDateTimeThe value to process.
firstDayOfWeekDayOfWeekSpecifies the first day of the week. Use the parameterless overload to pick up CurrentCulture's value automatically.
Returns
- DateTime
A new DateTime representing the end of the week.
EndOfYear(DateTime)
Returns a new DateTime that represents the last day of the year specified by the DateTime passed in.
public static DateTime EndOfYear(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the end of the year.
FirstOfHalf(DateTime)
Returns a new DateTime that represents the first day of the calendar half-year containing the specified DateTime. Halves are: H1 Jan-Jun, H2 Jul-Dec.
public static DateTime FirstOfHalf(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the first of the half-year at 00:00:00.
FirstOfMonth(DateTime)
Returns a new DateTime that represents the first day of the month specified by the DateTime passed in.
public static DateTime FirstOfMonth(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the first of the month.
FirstOfQuarter(DateTime)
Returns a new DateTime that represents the first day of the calendar quarter containing the specified DateTime. Quarters are: Q1 Jan-Mar, Q2 Apr-Jun, Q3 Jul-Sep, Q4 Oct-Dec.
public static DateTime FirstOfQuarter(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the first of the quarter at 00:00:00.
FirstOfWeek(DateTime)
Returns a new DateTime that represents the first day of the week specified by the DateTime passed in using the thread's CurrentCulture FirstDayOfWeek.
public static DateTime FirstOfWeek(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the first of the week.
FirstOfWeek(DateTime, DayOfWeek)
Returns a new DateTime that represents the first day of the week specified by the DateTime passed in using the specified firstDayOfWeek
public static DateTime FirstOfWeek(this DateTime dateTime, DayOfWeek firstDayOfWeek)
Parameters
dateTimeDateTimeThe value to process.
firstDayOfWeekDayOfWeekSpecifies the first day of the week.
Returns
- DateTime
A new DateTime representing the first of the week.
FirstOfYear(DateTime)
Returns a new DateTime that represents the first day of the year specified by the DateTime passed in.
public static DateTime FirstOfYear(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime representing the first of the year.
TruncateMilliseconds(DateTime)
Remove the milliseconds and everything after the milliseconds
public static DateTime TruncateMilliseconds(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime equal to the passed in value without milliseconds
TruncateSeconds(DateTime)
Remove the seconds and everything after the seconds
public static DateTime TruncateSeconds(this DateTime dateTime)
Parameters
dateTimeDateTimeThe value to process.
Returns
- DateTime
A new DateTime equal to the passed in value without seconds and milliseconds