Class DateTimeExtensions
Inheritance
DateTimeExtensions
Assembly: Glitch9.dll
Syntax
public static class DateTimeExtensions
Methods
|
Edit this page
View Source
GetDatesUntil(DateTime, DateTime)
Gets all dates from startDate to endDate, inclusive.
Declaration
public static IEnumerable<DateTime> GetDatesUntil(this DateTime startDate, DateTime endDate)
Parameters
Returns
|
Edit this page
View Source
GetDisplayName(DateTime, CultureInfo)
Gets a user-friendly display name for the DateTime.
If the date is today, it shows "Today HH:mm tt".
If the date is yesterday, it shows "Yesterday HH:mm tt".
If the date is within the current year, it shows "Month Day HH:mm tt" (e.g., July 4, 7:30 PM).
Otherwise, it shows the full date in the long date pattern.
Declaration
public static string GetDisplayName(this DateTime dt, CultureInfo cultureInfo = null)
Parameters
Returns
|
Edit this page
View Source
StartOfWeek(DateTime, DayOfWeek)
Gets the start of the week for the given date, based on the specified starting day of the week.
Declaration
public static DateTime StartOfWeek(this DateTime date, DayOfWeek startingDay)
Parameters
Returns
|
Edit this page
View Source
ToString(DateTime, string, string)
Converts the DateTime to a string using a different format if the date is in the current year.
Declaration
public static string ToString(this DateTime dt, string format, string currentYearFormat)
Parameters
| Type |
Name |
Description |
| DateTime |
dt |
The DateTime to format.
|
| string |
format |
The format string to use if the date is not in the current year.
|
| string |
currentYearFormat |
The format string to use if the date is in the current year.
|
Returns
| Type |
Description |
| string |
The formatted date string.
|
|
Edit this page
View Source
WeekOfMonth(DateTime)
Gets the week of the month for the given date.
Declaration
public static int WeekOfMonth(this DateTime date)
Parameters
Returns