DateTimeExtensions Members

The DateTimeExtensions type exposes the following members.

Methods


  Name Description
Public method Static member AddWorkdays
Adds the workdays. DateTime due = DateTime.Today.AddWorkdays(10); // due in 10 workdays
Public method Static member Age
Ages the specified date of birth. DateTime henrybirthdate = new DateTime(1998,10,12); int age = henrybirthdate.Age();
Public method Static member Ceiling
Ceiling the given DateTime object by the given time interval. i.e. 10:01 ceilinged by 10 minutes would be 10:10
Public method Static member 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);
Public method Static member Elapsed
Get the elapsed time since the input DateTime
Public method Static member FirstDayOfTheMonth
Retrieves the first day of the month of the date.
Public method Static member FirstDayOfWeekOfTheMonth
Firsts the day of week of the month.
Public method Static member Floor
Floor the given DateTime object by the given time interval. i.e. 10:09 floored by 10 minutes would be 10:00
Public method Static member GetDateRangeTo
Gets the date range to.
Public method Static member GetLastDayOfMonth
Gets the last day of month. Gets the last date of the month of the DateTime. DateTime lastDay = DateTime.Now.GetLastDayOfMonth();
Public method Static member Intersects
Intersectses the specified end date. Returns true if two date ranges intersect. bool eventsInterect = eventXStartDate.Intersects(eventXEndDate, eventYStartDate, eventYEndDate);
Public method Static member 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);
Public method Static member 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... }
Public method Static member IsLastDayOfTheMonth
Determines whether [is last day of the month].
Public method Static member IsLeapYear
Determines whether [is leap year].
Public method Static member IsWeekday
Determines whether this instance is weekday.
Public method Static member IsWeekend(DateTime)
Determines whether this instance is weekend. Lets you easily figure out ifdateTime holds a date value that is a weekend.
Public method Static member IsWeekend(DayOfWeek)
Determines whether this instance is weekend.
Public method Static member LastDayOfTheMonth
Retrieves the last day of the month of the date.
Public method Static member LastDayOfWeek
Retrieves the last day of the week that occurred since date.
Public method Static member LastDayOfWeekOfTheMonth
Lasts the day of week of the month.
Public method Static member NextDayOfWeek
Retrives the next day of the week that will occour after date.
Public method Static member NextSunday
Nexts the sunday. Get's the date of the upcoming Sunday.
Public method Static member Round
Round the given DateTime object by the given time interval. i.e. 10:09 rounded by 10 minutes would be 10:10
Public method Static member SetTime(DateTime, Int32)
Sets the time.
Public method Static member SetTime(DateTime, Int32, Int32)
Sets the time.
Public method Static member SetTime(DateTime, Int32, Int32, Int32)
Sets the time.
Public method Static member SetTime(DateTime, Int32, Int32, Int32, Int32)
Sets the time.
Public method Static member ThisWeekMonday
Thises the week monday. var monday = DateTime.Now.ThisWeekMonday();
Public method Static member ToDateTime
To the date time. var dt = TextBox1.Text.ToDateTime(); if (dt == null) { throw new Exception("Your datetime was invalid"); }
Public method Static member ToFriendlyDateString
To the friendly date string.
Public method Static member ToRFC822DateString
Converts a regular DateTime to a RFC822 date string used for RSS feeds
Public method Static member 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);