System.TimeSpan

Summary


Represents a time interval.
Defined in TimeSpan.js

Constructors

System.TimeSpan(<Int> days, <Int> hours, <Int> minutes, <Int> seconds, <Int> milliseconds)
Initializes a new TimeSpan to a specified number of days, hours, minutes, seconds, and milliseconds.

Parameters

  • days - Number of days.
  • hours - Number of hours.
  • minutes - Number of minutes.
  • seconds - Number of seconds.
  • milliseconds - Number of milliseconds.

Methods

  • TimeSpan Add(<TimeSpan> ts)
    Adds the specified TimeSpan to this instance.

    Parameters

    • ts - A TimeSpan.

    Return Values

    A TimeSpan that represents the value of this instance plus the value of ts.
  • TimeSpan Duration()
    Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object.

    Return Values

    A new TimeSpan whose value is the absolute value of the current TimeSpan object.
  • Boolean Equals(<TimeSpan> obj)
    Returns a value indicating whether this instance is equal to a specified TimeSpan object.

    Parameters

    • obj - A TimeSpan object to compare with this instance.

    Return Values

    true if obj represents the same time interval as this instance; otherwise, false.
  • Int GetDays()
    Gets the days component of the time interval represented by the current TimeSpan structure.

    Return Values

    The day component of this instance. The return value can be positive or negative.
  • Int GetHours()
    Gets the hours component of the time interval represented by the current TimeSpan structure.

    Return Values

    The hour component of the current TimeSpan structure. The return value ranges from -23 through 23.
  • Int GetMilliseconds()
    Gets the milliseconds component of the time interval represented by the current TimeSpan structure.

    Return Values

    The millisecond component of the current TimeSpan structure. The return value ranges from -999 through 999.
  • Int GetMinutes()
    Gets the minutes component of the time interval represented by the current TimeSpan structure.

    Return Values

    The minute component of the current TimeSpan structure. The return value ranges from -59 through 59.
  • Int GetSeconds()
    Gets the seconds component of the time interval represented by the current TimeSpan structure.

    Return Values

    The second component of the current TimeSpan structure. The return value ranges from -59 through 59.
  • Int GetTicks()
    Gets the number of ticks that represent the value of the current TimeSpan structure. The smallest unit of time is the tick, which is equal to 100 nanoseconds. A tick can be negative or positive.

    Return Values

    The number of ticks contained in this instance.
  • Float GetTotalDays()
    Gets the value of the current TimeSpan structure expressed in whole and fractional days.

    Return Values

    The total number of days represented by this instance.
  • Float GetTotalHours()
    Gets the value of the current TimeSpan structure expressed in whole and fractional hours.

    Return Values

    The total number of hours represented by this instance.
  • Float GetTotalMilliseconds()
    Gets the value of the current TimeSpan structure expressed in whole and fractional milliseconds.

    Return Values

    The total number of milliseconds represented by this instance.
  • Float GetTotalMinutes()
    Gets the value of the current TimeSpan structure expressed in whole and fractional minutes.

    Return Values

    The total number of minutes represented by this instance.
  • Float GetTotalSeconds()
    Gets the value of the current TimeSpan structure expressed in whole and fractional seconds.

    Return Values

    The total number of seconds represented by this instance.
  • TimeSpan Negate()
    Returns a TimeSpan whose value is the negated value of this instance.

    Return Values

    The same numeric value as this instance, but with the opposite sign.
  • TimeSpan Subtract(<TimeSpan> ts)
    Subtracts the specified TimeSpan from this instance.

    Parameters

    • ts - A TimeSpan.

    Return Values

    A TimeSpan that represents the value of this instance minus the value of ts.
  • String ToString()
    Returns the string representation of the value of this instance.

    Return Values

    A string that represents the value of this instance. The return value is of the form: [-][d.]hh:mm:ss[.fffffff]
  • static Int Compare(<TimeSpan> t1, <TimeSpan> t2)
    Compares two TimeSpan values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value.

    Parameters

    • t1 - A TimeSpan.
    • t2 - A TimeSpan.

    Return Values

    -1 if t1 is shorter than t2; 0 if t1 is equal to t2; 1 if t1 is longer than t2.
  • static TimeSpan FromTicks(<Int> value)
    Returns a TimeSpan that represents a specified time, where the specification is in units of ticks.

    Parameters

    • value - A number of ticks that represent a time.

    Return Values

    A TimeSpan with a value of value.