Table of Contents

Struct Duration

Namespace
UnitsNet
Assembly
UnitsNet.Duration.dll

Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them.

public struct Duration

Constructors

Duration(double, DurationUnit)

Creates the quantity with the given numeric value and unit.

public Duration(double value, DurationUnit unit)

Parameters

value double

The numeric value to construct this quantity with.

unit DurationUnit

The unit representation to construct this quantity with.

Exceptions

ArgumentException

If value is NaN or Infinity.

Properties

BaseUnit

The base unit of Duration, which is Second. All conversions go via this value.

public static DurationUnit BaseUnit { get; }

Property Value

DurationUnit

Days

Gets a double value of this quantity converted into Day

public double Days { get; }

Property Value

double

Hours

Gets a double value of this quantity converted into Hour

public double Hours { get; }

Property Value

double

JulianYears

Gets a double value of this quantity converted into JulianYear

public double JulianYears { get; }

Property Value

double

MaxValue

Represents the largest possible value of Duration.

public static Duration MaxValue { get; }

Property Value

Duration

Microseconds

Gets a double value of this quantity converted into Microsecond

public double Microseconds { get; }

Property Value

double

Milliseconds

Gets a double value of this quantity converted into Millisecond

public double Milliseconds { get; }

Property Value

double

MinValue

Represents the smallest possible value of Duration.

public static Duration MinValue { get; }

Property Value

Duration

Minutes

Gets a double value of this quantity converted into Minute

public double Minutes { get; }

Property Value

double

Months30

Gets a double value of this quantity converted into Month30

public double Months30 { get; }

Property Value

double

Nanoseconds

Gets a double value of this quantity converted into Nanosecond

public double Nanoseconds { get; }

Property Value

double

Seconds

Gets a double value of this quantity converted into Second

public double Seconds { get; }

Property Value

double

Sols

Gets a double value of this quantity converted into Sol

public double Sols { get; }

Property Value

double

Unit

public DurationUnit Unit { get; }

Property Value

DurationUnit

Value

The numeric value this quantity was constructed with.

public double Value { get; }

Property Value

double

Weeks

Gets a double value of this quantity converted into Week

public double Weeks { get; }

Property Value

double

Years365

Gets a double value of this quantity converted into Year365

public double Years365 { get; }

Property Value

double

Zero

Gets an instance of this quantity with a value of 0 in the base unit Second.

public static Duration Zero { get; }

Property Value

Duration

Methods

As(DurationUnit)

Convert to the unit representation unit.

public double As(DurationUnit unit)

Parameters

unit DurationUnit

Returns

double

Value converted to the specified unit.

From(double, DurationUnit)

Dynamically convert from value and unit enum DurationUnit to Duration.

public static Duration From(double value, DurationUnit fromUnit)

Parameters

value double

Value to convert from.

fromUnit DurationUnit

Unit to convert from.

Returns

Duration

Duration unit value.

FromDays(double)

Creates a Duration from Day.

public static Duration FromDays(double days)

Parameters

days double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromHours(double)

Creates a Duration from Hour.

public static Duration FromHours(double hours)

Parameters

hours double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromJulianYears(double)

Creates a Duration from JulianYear.

public static Duration FromJulianYears(double julianyears)

Parameters

julianyears double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromMicroseconds(double)

Creates a Duration from Microsecond.

public static Duration FromMicroseconds(double microseconds)

Parameters

microseconds double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromMilliseconds(double)

Creates a Duration from Millisecond.

public static Duration FromMilliseconds(double milliseconds)

Parameters

milliseconds double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromMinutes(double)

Creates a Duration from Minute.

public static Duration FromMinutes(double minutes)

Parameters

minutes double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromMonths30(double)

Creates a Duration from Month30.

public static Duration FromMonths30(double months30)

Parameters

months30 double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromNanoseconds(double)

Creates a Duration from Nanosecond.

public static Duration FromNanoseconds(double nanoseconds)

Parameters

nanoseconds double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromSeconds(double)

Creates a Duration from Second.

public static Duration FromSeconds(double seconds)

Parameters

seconds double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromSols(double)

Creates a Duration from Sol.

public static Duration FromSols(double sols)

Parameters

sols double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromWeeks(double)

Creates a Duration from Week.

public static Duration FromWeeks(double weeks)

Parameters

weeks double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

FromYears365(double)

Creates a Duration from Year365.

public static Duration FromYears365(double years365)

Parameters

years365 double

Returns

Duration

Exceptions

ArgumentException

If value is NaN or Infinity.

ToUnit(DurationUnit)

Converts this Duration to another Duration with the unit representation unit.

public Duration ToUnit(DurationUnit unit)

Parameters

unit DurationUnit

Returns

Duration

A Duration with the specified unit.