Search Results for

    Show / Hide Table of Contents

    Class DateTimeExtensions

    Defines a collection of extensions for a date/time object.

    Inheritance
    System.Object
    DateTimeExtensions
    Namespace: MADE.Data.Converters.Extensions
    Assembly: MADE.Data.Converters.dll
    Syntax
    public static class DateTimeExtensions : object

    Methods

    | Improve this Doc View Source

    EndOfDay(DateTime)

    Gets the end of the day represented by the specified object.

    Declaration
    public static DateTime EndOfDay(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The .

    Returns
    Type Description
    DateTime

    A new object with the same date as this instance, and the time value set to just before midnight of the next day.

    | Improve this Doc View Source

    EndOfMonth(DateTime)

    Gets the last day of the month represented by the specified object.

    Declaration
    public static DateTime EndOfMonth(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The .

    Returns
    Type Description
    DateTime

    A new object with the last day of the month for this instance, and the time value set to just before midnight of the next day.

    | Improve this Doc View Source

    EndOfWeek(DateTime)

    Gets the last day of the week represented by the specified object.

    Declaration
    public static DateTime EndOfWeek(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The .

    Returns
    Type Description
    DateTime

    A new object with the last day of the week for this instance, and the time value set to just before midnight of the next day.

    | Improve this Doc View Source

    EndOfYear(DateTime)

    Gets the last day of the year represented by the specified object.

    Declaration
    public static DateTime EndOfYear(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The .

    Returns
    Type Description
    DateTime

    A new object with the last day of the year for this instance, and the time value set to just before midnight of the next day.

    | Improve this Doc View Source

    SetTime(DateTime, Int32, Int32)

    Sets the time value of a date/time value.

    Declaration
    public static DateTime SetTime(this DateTime dateTime, int hours, int minutes)
    Parameters
    Type Name Description
    DateTime dateTime

    The date/time value to add a time to.

    System.Int32 hours

    The hours to set on the date/time value.

    System.Int32 minutes

    The minutes to set on the date/time value.

    Returns
    Type Description
    DateTime

    The updated date/time with the given time value.

    | Improve this Doc View Source

    SetTime(DateTime, Int32, Int32, Int32)

    Sets the time value of a date/time value.

    Declaration
    public static DateTime SetTime(this DateTime dateTime, int hours, int minutes, int seconds)
    Parameters
    Type Name Description
    DateTime dateTime

    The date/time value to add a time to.

    System.Int32 hours

    The hours to set on the date/time value.

    System.Int32 minutes

    The minutes to set on the date/time value.

    System.Int32 seconds

    The seconds to set on the date/time value.

    Returns
    Type Description
    DateTime

    The updated date/time with the given time value.

    | Improve this Doc View Source

    SetTime(DateTime, Int32, Int32, Int32, Int32)

    Sets the time value of a date/time value.

    Declaration
    public static DateTime SetTime(this DateTime dateTime, int hours, int minutes, int seconds, int milliseconds)
    Parameters
    Type Name Description
    DateTime dateTime

    The date/time value to add a time to.

    System.Int32 hours

    The hours to set on the date/time value.

    System.Int32 minutes

    The minutes to set on the date/time value.

    System.Int32 seconds

    The seconds to set on the date/time value.

    System.Int32 milliseconds

    The milliseconds to set on the date/time value.

    Returns
    Type Description
    DateTime

    The updated date/time with the given time value.

    | Improve this Doc View Source

    SetTime(DateTime, TimeSpan)

    Sets the time value of a date/time value.

    Declaration
    public static DateTime SetTime(this DateTime dateTime, TimeSpan timeSpan)
    Parameters
    Type Name Description
    DateTime dateTime

    The date/time value to add a time to.

    TimeSpan timeSpan

    The time to set on the date/time value.

    Returns
    Type Description
    DateTime

    The updated date/time with the given time value.

    | Improve this Doc View Source

    SetTime(Nullable<DateTime>, Int32, Int32)

    Sets the time value of a nullable date/time value.

    Declaration
    public static DateTime? SetTime(this DateTime? dateTime, int hours, int minutes)
    Parameters
    Type Name Description
    System.Nullable<DateTime> dateTime

    The nullable date/time value to add a time to.

    System.Int32 hours

    The hours to set on the date/time value.

    System.Int32 minutes

    The minutes to set on the date/time value.

    Returns
    Type Description
    System.Nullable<DateTime>

    The updated date/time with the given time value.

    | Improve this Doc View Source

    SetTime(Nullable<DateTime>, Int32, Int32, Int32)

    Sets the time value of a nullable date/time value.

    Declaration
    public static DateTime? SetTime(this DateTime? dateTime, int hours, int minutes, int seconds)
    Parameters
    Type Name Description
    System.Nullable<DateTime> dateTime

    The nullable date/time value to add a time to.

    System.Int32 hours

    The hours to set on the date/time value.

    System.Int32 minutes

    The minutes to set on the date/time value.

    System.Int32 seconds

    The seconds to set on the date/time value.

    Returns
    Type Description
    System.Nullable<DateTime>

    The updated date/time with the given time value.

    | Improve this Doc View Source

    SetTime(Nullable<DateTime>, Int32, Int32, Int32, Int32)

    Sets the time value of a nullable date/time value.

    Declaration
    public static DateTime? SetTime(this DateTime? dateTime, int hours, int minutes, int seconds, int milliseconds)
    Parameters
    Type Name Description
    System.Nullable<DateTime> dateTime

    The nullable date/time value to add a time to.

    System.Int32 hours

    The hours to set on the date/time value.

    System.Int32 minutes

    The minutes to set on the date/time value.

    System.Int32 seconds

    The seconds to set on the date/time value.

    System.Int32 milliseconds

    The milliseconds to set on the date/time value.

    Returns
    Type Description
    System.Nullable<DateTime>

    The updated date/time with the given time value.

    | Improve this Doc View Source

    SetTime(Nullable<DateTime>, TimeSpan)

    Sets the time value of a nullable date/time value.

    Declaration
    public static DateTime? SetTime(this DateTime? dateTime, TimeSpan timeSpan)
    Parameters
    Type Name Description
    System.Nullable<DateTime> dateTime

    The nullable date/time value to add a time to.

    TimeSpan timeSpan

    The time to set on the date/time value.

    Returns
    Type Description
    System.Nullable<DateTime>

    The updated date/time with the given time value.

    | Improve this Doc View Source

    StartOfDay(DateTime)

    Gets the start of the day represented by the specified object.

    Declaration
    public static DateTime StartOfDay(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The .

    Returns
    Type Description
    DateTime

    A new object with the same date as this instance, and the time value set to midnight.

    | Improve this Doc View Source

    StartOfMonth(DateTime)

    Gets the first day of the month represented by the specified object.

    Declaration
    public static DateTime StartOfMonth(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The .

    Returns
    Type Description
    DateTime

    A new object with the first day of the month for this instance, and the time value set to midnight.

    | Improve this Doc View Source

    StartOfWeek(DateTime)

    Gets the first day of the week represented by the specified object.

    Declaration
    public static DateTime StartOfWeek(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The .

    Returns
    Type Description
    DateTime

    A new object with the first day of the week for this instance, and the time value set to midnight.

    | Improve this Doc View Source

    StartOfYear(DateTime)

    Gets the first day of the year represented by the specified object.

    Declaration
    public static DateTime StartOfYear(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The .

    Returns
    Type Description
    DateTime

    A new object with the first day of the year for this instance, and the time value set to midnight.

    | Improve this Doc View Source

    ToCurrentAge(DateTime)

    Gets the current age in years based on the specified starting date and today's date.

    Declaration
    public static int ToCurrentAge(this DateTime startingDate)
    Parameters
    Type Name Description
    DateTime startingDate

    The starting date.

    Returns
    Type Description
    System.Int32

    An integer value representing the number of years.

    | Improve this Doc View Source

    ToDaySuffix(DateTime)

    Gets the day suffix for the specified date, i.e. st, nd, rd, or th.

    Declaration
    public static string ToDaySuffix(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The date to get a day suffix for.

    Returns
    Type Description
    System.String

    The day suffix as a string.

    | Improve this Doc View Source

    ToNearestHour(DateTime)

    Rounds a value to its nearest hour.

    This is determined by the half hour of each hour, rounding up or down.

    Declaration
    public static DateTime ToNearestHour(this DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    The to round.

    Returns
    Type Description
    DateTime

    The updated .

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright (c) MADE Apps