Search Results for

    Show / Hide Table of Contents

    Class DateTimeAndTimeSpanExtensions

    Extensions for the DateTime and TimeSpan structs.

    Inheritance
    Object
    DateTimeAndTimeSpanExtensions
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: System
    Assembly: Acoustics.Shared.dll
    Syntax
    public static class DateTimeAndTimeSpanExtensions

    Methods

    | Improve this Doc View Source

    Absolute(TimeSpan)

    Declaration
    public static TimeSpan Absolute(this TimeSpan span)
    Parameters
    Type Name Description
    TimeSpan span
    Returns
    Type Description
    TimeSpan
    | Improve this Doc View Source

    Ceiling(DateTimeOffset, TimeSpan)

    Declaration
    public static DateTimeOffset Ceiling(this DateTimeOffset date, TimeSpan interval)
    Parameters
    Type Name Description
    DateTimeOffset date
    TimeSpan interval
    Returns
    Type Description
    DateTimeOffset
    | Improve this Doc View Source

    Divide(TimeSpan, Double)

    Divides a timespan by an scalar value.

    Declaration
    public static TimeSpan Divide(this TimeSpan dividend, double divisor)
    Parameters
    Type Name Description
    TimeSpan dividend
    Double divisor
    Returns
    Type Description
    TimeSpan
    | Improve this Doc View Source

    Divide(TimeSpan, Int32)

    Divides a timespan by an scalar value.

    Declaration
    public static TimeSpan Divide(this TimeSpan dividend, int divisor)
    Parameters
    Type Name Description
    TimeSpan dividend
    Int32 divisor
    Returns
    Type Description
    TimeSpan
    | Improve this Doc View Source

    Divide(TimeSpan, TimeSpan)

    Divides a timespan by an timespan and returns a scalar factor.

    Declaration
    public static double Divide(this TimeSpan dividend, TimeSpan divisor)
    Parameters
    Type Name Description
    TimeSpan dividend
    TimeSpan divisor
    Returns
    Type Description
    Double
    | Improve this Doc View Source

    Floor(DateTimeOffset, TimeSpan)

    Declaration
    public static DateTimeOffset Floor(this DateTimeOffset date, TimeSpan interval)
    Parameters
    Type Name Description
    DateTimeOffset date
    TimeSpan interval
    Returns
    Type Description
    DateTimeOffset
    | Improve this Doc View Source

    Humanise(DateTime, DateTime, Boolean)

    Get a human-readable string of difference between two DateTimes (eg. 2 hours, 2 hours ago, in 2 hours).

    Declaration
    public static string Humanise(this DateTime first, DateTime second, bool addSuffixOrPrefix = false)
    Parameters
    Type Name Description
    DateTime first

    First time (should be earlier).

    DateTime second

    Second time (should be later).

    Boolean addSuffixOrPrefix

    The add Suffix Or Prefix.

    Returns
    Type Description
    String

    Human-readable string of difference between two DateTimes.

    | Improve this Doc View Source

    Humanise(DateTimeOffset, DateTimeOffset, Boolean)

    Get a human-readable string of difference between two DateTimes (eg. 2 hours, 2 hours ago, in 2 hours).

    Declaration
    public static string Humanise(this DateTimeOffset first, DateTimeOffset second, bool addSuffixOrPrefix = false)
    Parameters
    Type Name Description
    DateTimeOffset first

    First time (should be earlier).

    DateTimeOffset second

    Second time (should be later).

    Boolean addSuffixOrPrefix

    The add Suffix Or Prefix.

    Returns
    Type Description
    String

    Human-readable string of difference between two DateTimes.

    | Improve this Doc View Source

    Humanise(TimeSpan, Boolean)

    Get a human readable representation of the time span.

    Declaration
    public static string Humanise(this TimeSpan timeSpan, bool addSuffixOrPrefix = false)
    Parameters
    Type Name Description
    TimeSpan timeSpan

    The time span.

    Boolean addSuffixOrPrefix

    True to add a suffix or prefix as appropriate. False to not add a suffix or prefix.

    Returns
    Type Description
    String

    Human readable representation of the time span.

    | Improve this Doc View Source

    Max(TimeSpan, TimeSpan)

    Declaration
    public static TimeSpan Max(this TimeSpan t1, TimeSpan t2)
    Parameters
    Type Name Description
    TimeSpan t1
    TimeSpan t2
    Returns
    Type Description
    TimeSpan
    | Improve this Doc View Source

    Min(TimeSpan, TimeSpan)

    Declaration
    public static TimeSpan Min(this TimeSpan t1, TimeSpan t2)
    Parameters
    Type Name Description
    TimeSpan t1
    TimeSpan t2
    Returns
    Type Description
    TimeSpan
    | Improve this Doc View Source

    Modulo(TimeSpan, TimeSpan)

    Divides a timespan by an timespan and the remainder.

    Declaration
    public static TimeSpan Modulo(this TimeSpan dividend, TimeSpan divisor)
    Parameters
    Type Name Description
    TimeSpan dividend
    TimeSpan divisor
    Returns
    Type Description
    TimeSpan
    | Improve this Doc View Source

    Multiply(TimeSpan, Double)

    Multiplies a timespan by a double value.

    Declaration
    public static TimeSpan Multiply(this TimeSpan multiplicand, double multiplier)
    Parameters
    Type Name Description
    TimeSpan multiplicand
    Double multiplier
    Returns
    Type Description
    TimeSpan
    | Improve this Doc View Source

    Multiply(TimeSpan, Int32)

    Multiplies a timespan by a scalar value.

    Declaration
    public static TimeSpan Multiply(this TimeSpan multiplicand, int multiplier)
    Parameters
    Type Name Description
    TimeSpan multiplicand
    Int32 multiplier
    Returns
    Type Description
    TimeSpan
    | Improve this Doc View Source

    Round(DateTime, TimeSpan)

    Declaration
    public static DateTime Round(this DateTime datetime, TimeSpan roundingInterval)
    Parameters
    Type Name Description
    DateTime datetime
    TimeSpan roundingInterval
    Returns
    Type Description
    DateTime
    Remarks

    From: http://stackoverflow.com/questions/766626/is-there-a-better-way-in-c-sharp-to-round-a-datetime-to-the-nearest-5-seconds (Stackoverflow).

    | Improve this Doc View Source

    Round(DateTimeOffset, TimeSpan)

    Declaration
    public static DateTimeOffset Round(this DateTimeOffset date, TimeSpan roundingInterval)
    Parameters
    Type Name Description
    DateTimeOffset date
    TimeSpan roundingInterval
    Returns
    Type Description
    DateTimeOffset
    | Improve this Doc View Source

    Round(TimeSpan, TimeSpan)

    Declaration
    public static TimeSpan Round(this TimeSpan time, TimeSpan roundingInterval)
    Parameters
    Type Name Description
    TimeSpan time
    TimeSpan roundingInterval
    Returns
    Type Description
    TimeSpan
    Remarks

    From: http://stackoverflow.com/questions/766626/is-there-a-better-way-in-c-sharp-to-round-a-datetime-to-the-nearest-5-seconds (Stackoverflow).

    | Improve this Doc View Source

    Round(TimeSpan, TimeSpan, MidpointRounding)

    Declaration
    public static TimeSpan Round(this TimeSpan time, TimeSpan roundingInterval, MidpointRounding roundingType)
    Parameters
    Type Name Description
    TimeSpan time
    TimeSpan roundingInterval
    MidpointRounding roundingType
    Returns
    Type Description
    TimeSpan
    Remarks

    From: http://stackoverflow.com/questions/766626/is-there-a-better-way-in-c-sharp-to-round-a-datetime-to-the-nearest-5-seconds (Stackoverflow).

    | Improve this Doc View Source

    RoundToTimeOfDay(DateTimeOffset, TimeSpan, DateTimeAndTimeSpanExtensions.RoundingDirection)

    Round a date to a time of day.

    Declaration
    public static DateTimeOffset RoundToTimeOfDay(this DateTimeOffset date, TimeSpan timeOfDay, DateTimeAndTimeSpanExtensions.RoundingDirection direction)
    Parameters
    Type Name Description
    DateTimeOffset date

    The date to round.

    TimeSpan timeOfDay

    The time of day to round to.

    DateTimeAndTimeSpanExtensions.RoundingDirection direction

    The behaviour of the rounding operation.

    Returns
    Type Description
    DateTimeOffset

    A rounded date.

    Remarks

    Unlike the other rounding methods (which accept an interval), this method will only output values that are 24-hours apart so that values always align to the supplied timeOfDay.

    | Improve this Doc View Source

    ToIso8601SafeString(DateTimeOffset)

    Formats a date in an ISO8601 format that is compact and does not contain colons.

    Declaration
    public static string ToIso8601SafeString(this DateTimeOffset date)
    Parameters
    Type Name Description
    DateTimeOffset date

    The date to convert to a string.

    Returns
    Type Description
    String

    The resulting string.

    | Improve this Doc View Source

    ToJavascriptTimestamp(DateTime)

    Gets the DateTime formatted as a javascript timestamp.

    Declaration
    public static long ToJavascriptTimestamp(this DateTime value)
    Parameters
    Type Name Description
    DateTime value

    The value.

    Returns
    Type Description
    Int64

    Javascript timestamp.

    | Improve this Doc View Source

    ToJavascriptTimestamp(DateTimeOffset)

    Gets the DateTimeOffset formatted as a javascript timestamp.

    Declaration
    public static long ToJavascriptTimestamp(this DateTimeOffset value)
    Parameters
    Type Name Description
    DateTimeOffset value

    The value.

    Returns
    Type Description
    Int64

    Javascript timestamp.

    | Improve this Doc View Source

    ToTimeZoneString(TimeSpan)

    Gets the minutes and seconds of a time span in the format required for an offset from UTC.

    Declaration
    public static string ToTimeZoneString(this TimeSpan ts)
    Parameters
    Type Name Description
    TimeSpan ts

    The time span.

    Returns
    Type Description
    String

    Time zone offset formatted string.

    • Improve this Doc
    • View Source
    In This Article
    • Methods
      • Absolute(TimeSpan)
      • Ceiling(DateTimeOffset, TimeSpan)
      • Divide(TimeSpan, Double)
      • Divide(TimeSpan, Int32)
      • Divide(TimeSpan, TimeSpan)
      • Floor(DateTimeOffset, TimeSpan)
      • Humanise(DateTime, DateTime, Boolean)
      • Humanise(DateTimeOffset, DateTimeOffset, Boolean)
      • Humanise(TimeSpan, Boolean)
      • Max(TimeSpan, TimeSpan)
      • Min(TimeSpan, TimeSpan)
      • Modulo(TimeSpan, TimeSpan)
      • Multiply(TimeSpan, Double)
      • Multiply(TimeSpan, Int32)
      • Round(DateTime, TimeSpan)
      • Round(DateTimeOffset, TimeSpan)
      • Round(TimeSpan, TimeSpan)
      • Round(TimeSpan, TimeSpan, MidpointRounding)
      • RoundToTimeOfDay(DateTimeOffset, TimeSpan, DateTimeAndTimeSpanExtensions.RoundingDirection)
      • ToIso8601SafeString(DateTimeOffset)
      • ToJavascriptTimestamp(DateTime)
      • ToJavascriptTimestamp(DateTimeOffset)
      • ToTimeZoneString(TimeSpan)
    Generated by DocFX AP docs version: 21.7.0.4-master-e26127a50d7bd7472d47288f10e61014fb981f7f-DIRTY-CI:144 Back to top