Class DateTimeExtensions
All DateTime extensions.
Inherited Members
Namespace: Code.Library.Extensions
Assembly: Code.Library.dll
Syntax
public static class DateTimeExtensions
Methods
| Improve this Doc View SourceConvertTo12H(TimeSpan)
Convert timespan to 12H format string.
Declaration
public static string ConvertTo12H(this TimeSpan timeSpan)
Parameters
| Type | Name | Description |
|---|---|---|
| Time |
timeSpan | Input timespan. |
Returns
| Type | Description |
|---|---|
| string | Twelve hour format string. |
DaysInMonth(DateTime)
Returns the number of days in the month of specified date.
Declaration
public static int DaysInMonth(this DateTime value)
Parameters
| Type | Name | Description |
|---|---|---|
| Date |
value | datetime. |
Returns
| Type | Description |
|---|---|
| int | Number of days in the month of the specified date. |
FirstDayOfMonth(DateTime)
Returns the first day in the month of specified date.
Declaration
public static DateTime FirstDayOfMonth(this DateTime value)
Parameters
| Type | Name | Description |
|---|---|---|
| Date |
value | Input date. |
Returns
| Type | Description |
|---|---|
| Date |
First date of the month of the specified date. |
FirstDayOfYear(DateTime)
Returns the first day in the year of the given date.
Declaration
public static DateTime FirstDayOfYear(this DateTime date)
Parameters
| Type | Name | Description |
|---|---|---|
| Date |
date | The date. |
Returns
| Improve this Doc View SourceFromUnixTime(long)
Converts unix time to datetime.
Declaration
public static DateTime FromUnixTime(this long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | unix value. |
Returns
| Type | Description |
|---|---|
| Date |
DateTime. |
GetEachDay(DateTime, DateTime)
Gives list of days between start and end date.
Declaration
public static IEnumerable<DateTime> GetEachDay(this DateTime startDate, DateTime endDate)
Parameters
Returns
| Type | Description |
|---|---|
| IEnumerable<Date |
Iso8601ToDateTime(string)
Converts ISO 8601 time to datetime.
Declaration
public static DateTime Iso8601ToDateTime(this string iso8601text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | iso8601text | ISO string. |
Returns
| Type | Description |
|---|---|
| Date |
DateTime. |
LastDayOfMonth(DateTime)
Returns the last day in the month of specified date.
Declaration
public static DateTime LastDayOfMonth(this DateTime value)
Parameters
| Type | Name | Description |
|---|---|---|
| Date |
value | Input datetime. |
Returns
| Type | Description |
|---|---|
| Date |
last day as DateTime in the month of the specified date. |
NameOfMonth(DateTime)
Returns the name of month of the specified date.
Declaration
public static string NameOfMonth(this DateTime value)
Parameters
| Type | Name | Description |
|---|---|---|
| Date |
value | Input datetime. |
Returns
| Type | Description |
|---|---|
| string | Name of the month. |
ToIso8601(DateTime)
Returns the Iso 8601 format of the specified date.
Declaration
public static string ToIso8601(this DateTime date)
Parameters
| Type | Name | Description |
|---|---|---|
| Date |
date | Input datetime. |
Returns
| Type | Description |
|---|---|
| string | Iso8601 string for the specified datetime. |
ToUnixTime(DateTime)
Converts datetime value to unix time.
Declaration
public static long ToUnixTime(this DateTime value)
Parameters
| Type | Name | Description |
|---|---|---|
| Date |
value | Input datetime. |
Returns
| Type | Description |
|---|---|
| long | UnixTime. |
Exceptions
| Type | Condition |
|---|---|
| Argument |
Specified value is lower than the UNIX time. |