Search Results for

    Show / Hide Table of Contents

    Class DateTimeExtensions

    Inheritance
    object
    DateTimeExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Glitch9
    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
    Type Name Description
    DateTime startDate
    DateTime endDate
    Returns
    Type Description
    IEnumerable<DateTime>
    | 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
    Type Name Description
    DateTime dt
    CultureInfo cultureInfo
    Returns
    Type Description
    string
    | 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
    Type Name Description
    DateTime date
    DayOfWeek startingDay
    Returns
    Type Description
    DateTime
    | 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
    Type Name Description
    DateTime date
    Returns
    Type Description
    int
    • Edit this page
    • View Source
    In this article
    Back to top AI DevKit Documentation