Class DateTimeExtensions
Extension methods for the DateTime object.
Inheritance
Inherited Members
Namespace: JK.Common.Extensions
Assembly: JK.Common.dll
Syntax
public static class DateTimeExtensions
Methods
| Improve this Doc View SourceAddWorkDays(DateTime, in Int32)
Adds given number of business days to a date.
Declaration
public static DateTime AddWorkDays(this DateTime dt, in int days)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
System.Int32 | days | Number of days to add (can be negative). |
Returns
Type | Description |
---|---|
System.DateTime | The date the given amount of business days from the start date. |
CalculateAge(DateTime, in DateTime)
Calculates age of an individual.
Declaration
public static int CalculateAge(this DateTime dt, in DateTime birthday)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
System.DateTime | birthday | Date of birth. |
Returns
Type | Description |
---|---|
System.Int32 | Age from birth date to given date. |
GetAbbreviatedDayName(DateTime)
Gets the abbreviated day name.
Declaration
public static string GetAbbreviatedDayName(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
Returns
Type | Description |
---|---|
System.String | Abbreviated day name. |
GetAbbreviatedMonthName(DateTime)
Gets the abbreviated month name.
Declaration
public static string GetAbbreviatedMonthName(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
Returns
Type | Description |
---|---|
System.String | Abbreviated month name. |
GetDayName(DateTime)
Gets the full name of a given day.
Declaration
public static string GetDayName(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
Returns
Type | Description |
---|---|
System.String | Full day name. |
GetMonthName(DateTime)
Gets the full name of a month.
Declaration
public static string GetMonthName(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
Returns
Type | Description |
---|---|
System.String | Full month name. |
IsBetween(DateTime, in DateTime, in DateTime)
Determines whether or not a given date is between (inclusive) the given start and end dates.
Declaration
public static bool IsBetween(this DateTime dt, in DateTime start, in DateTime end)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
System.DateTime | start | Start of date range to check |
System.DateTime | end | End of date range to check |
Returns
Type | Description |
---|---|
System.Boolean | True if date falls within range, otherwise false |
IsWeekday(DateTime)
Determines if given date is a weekday.
Declaration
public static bool IsWeekday(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
Returns
Type | Description |
---|---|
System.Boolean | True if is a weekday, otherwise false. |
IsWeekend(DateTime)
Determines if given date is a weekday.
Declaration
public static bool IsWeekend(this DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | Current DateTime object from extension method. |
Returns
Type | Description |
---|---|
System.Boolean | True if is a weekend, otherwise false. |