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

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

dateTime DateTime

The value to process.

Returns

DateTime

A new DateTime representing the end of the month.

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

dateTime DateTime

The 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

dateTime DateTime

The value to process.

firstDayOfWeek DayOfWeek

Specifies the first day of the week. Default is Sunday.

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

dateTime DateTime

The value to process.

Returns

DateTime

A new DateTime representing the end of the year.

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

dateTime DateTime

The value to process.

Returns

DateTime

A new DateTime representing the first of the month.

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

dateTime DateTime

The 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

dateTime DateTime

The value to process.

firstDayOfWeek DayOfWeek

Specifies 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

dateTime DateTime

The 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

dateTime DateTime

The 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

dateTime DateTime

The value to process.

Returns

DateTime

A new DateTime equal to the passed in value without seconds and milliseconds