DateTimeExtensions Members
The DateTimeExtensions type exposes the following members.
Methods
Name | Description | |
---|---|---|
![]() ![]() |
AddWorkdays |
Adds the workdays.
DateTime due = DateTime.Today.AddWorkdays(10); // due in 10 workdays
|
![]() ![]() |
Age |
Ages the specified date of birth.
DateTime henrybirthdate = new DateTime(1998,10,12);
int age = henrybirthdate.Age();
|
![]() ![]() |
Ceiling |
Ceiling the given DateTime object by the given time interval. i.e. 10:01 ceilinged by 10 minutes would be 10:10
|
![]() ![]() |
DateDiff |
DateDiff in SQL style.
Datepart implemented:
"year" (abbr. "yy", "yyyy"),
"quarter" (abbr. "qq", "q"),
"month" (abbr. "mm", "m"),
"day" (abbr. "dd", "d"),
"week" (abbr. "wk", "ww"),
"hour" (abbr. "hh"),
"minute" (abbr. "mi", "n"),
"second" (abbr. "ss", "s"),
"millisecond" (abbr. "ms").
Gets the total days from 01/01/2000.
DateTime dt = new DateTime(2000, 01, 01);
Int64 days = dt.DateDiff("day", DateTime.Now);
Gets the total hours from 01/01/2000.
Int64 hours = dt.DateDiff("hour", DateTime.Now);
|
![]() ![]() |
Elapsed |
Get the elapsed time since the input DateTime
|
![]() ![]() |
FirstDayOfTheMonth |
Retrieves the first day of the month of the date.
|
![]() ![]() |
FirstDayOfWeekOfTheMonth |
Firsts the day of week of the month.
|
![]() ![]() |
Floor |
Floor the given DateTime object by the given time interval. i.e. 10:09 floored by 10 minutes would be 10:00
|
![]() ![]() |
GetDateRangeTo |
Gets the date range to.
|
![]() ![]() |
GetLastDayOfMonth |
Gets the last day of month.
Gets the last date of the month of the DateTime.
DateTime lastDay = DateTime.Now.GetLastDayOfMonth();
|
![]() ![]() |
Intersects |
Intersectses the specified end date.
Returns true if two date ranges intersect.
bool eventsInterect = eventXStartDate.Intersects(eventXEndDate, eventYStartDate, eventYEndDate);
|
![]() ![]() |
IsBetween |
Determines whether the specified start date is between.
Checks if the date is between the two provided dates
var today = DateTime.Now;
var start = new DateTime(2012, 1, 1);
var end = new DateTime(2013, 11, 25);
Boolean isBetween = today.IsBetween(start, end);
|
![]() ![]() |
IsInRange |
Determines whether [is in range] [the specified begin date].
var monday = DateTime.Now.ThisWeekMonday();
var friday = DateTime.Now.ThisWeekFriday();
if(DateTime.Now.IsInRange(monday, friday)
{
...do something...
}
|
![]() ![]() |
IsLastDayOfTheMonth |
Determines whether [is last day of the month].
|
![]() ![]() |
IsLeapYear |
Determines whether [is leap year].
|
![]() ![]() |
IsWeekday |
Determines whether this instance is weekday.
|
![]() ![]() |
IsWeekend(DateTime) |
Determines whether this instance is weekend.
Lets you easily figure out ifdateTime holds a date value that is a weekend.
|
![]() ![]() |
IsWeekend(DayOfWeek) |
Determines whether this instance is weekend.
|
![]() ![]() |
LastDayOfTheMonth |
Retrieves the last day of the month of the date.
|
![]() ![]() |
LastDayOfWeek |
Retrieves the last day of the week that occurred since date.
|
![]() ![]() |
LastDayOfWeekOfTheMonth |
Lasts the day of week of the month.
|
![]() ![]() |
NextDayOfWeek |
Retrives the next day of the week that will occour after date.
|
![]() ![]() |
NextSunday |
Nexts the sunday.
Get's the date of the upcoming Sunday.
|
![]() ![]() |
Round |
Round the given DateTime object by the given time interval. i.e. 10:09 rounded by 10 minutes would be 10:10
|
![]() ![]() |
SetTime(DateTime, Int32) |
Sets the time.
|
![]() ![]() |
SetTime(DateTime, Int32, Int32) |
Sets the time.
|
![]() ![]() |
SetTime(DateTime, Int32, Int32, Int32) |
Sets the time.
|
![]() ![]() |
SetTime(DateTime, Int32, Int32, Int32, Int32) |
Sets the time.
|
![]() ![]() |
ThisWeekMonday |
Thises the week monday.
var monday = DateTime.Now.ThisWeekMonday();
|
![]() ![]() |
ToDateTime |
To the date time.
var dt = TextBox1.Text.ToDateTime();
if (dt == null) {
throw new Exception("Your datetime was invalid");
}
|
![]() ![]() |
ToFriendlyDateString |
To the friendly date string.
|
![]() ![]() |
ToRFC822DateString |
Converts a regular DateTime to a RFC822 date string used for RSS feeds
|
![]() ![]() |
ToStringFormat |
To the string format.
var shortDateResult = DateTime.Now.ToStringFormat(() => DateTimeFormat.ShortDate);
var fullLongDateTimeResult = DateTime.Now.ToStringFormat(() => DateTimeFormat.FullLongDateTime);
var rfc1123Result = DateTime.Now.ToStringFormat(() => DateTimeFormat.Rfc1123LowerCase);
|