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
valuedoubleThe numeric value to construct this quantity with.
unitDurationUnitThe 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
Days
public double Days { get; }
Property Value
Hours
public double Hours { get; }
Property Value
JulianYears
Gets a double value of this quantity converted into JulianYear
public double JulianYears { get; }
Property Value
MaxValue
Represents the largest possible value of Duration.
public static Duration MaxValue { get; }
Property Value
Microseconds
Gets a double value of this quantity converted into Microsecond
public double Microseconds { get; }
Property Value
Milliseconds
Gets a double value of this quantity converted into Millisecond
public double Milliseconds { get; }
Property Value
MinValue
Represents the smallest possible value of Duration.
public static Duration MinValue { get; }
Property Value
Minutes
public double Minutes { get; }
Property Value
Months30
public double Months30 { get; }
Property Value
Nanoseconds
Gets a double value of this quantity converted into Nanosecond
public double Nanoseconds { get; }
Property Value
Seconds
public double Seconds { get; }
Property Value
Sols
public double Sols { get; }
Property Value
Unit
public DurationUnit Unit { get; }
Property Value
Value
The numeric value this quantity was constructed with.
public double Value { get; }
Property Value
Weeks
public double Weeks { get; }
Property Value
Years365
public double Years365 { get; }
Property Value
Zero
Gets an instance of this quantity with a value of 0 in the base unit Second.
public static Duration Zero { get; }
Property Value
Methods
As(DurationUnit)
Convert to the unit representation unit.
public double As(DurationUnit unit)
Parameters
unitDurationUnit
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
valuedoubleValue to convert from.
fromUnitDurationUnitUnit to convert from.
Returns
- Duration
Duration unit value.
FromDays(double)
public static Duration FromDays(double days)
Parameters
daysdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromHours(double)
public static Duration FromHours(double hours)
Parameters
hoursdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromJulianYears(double)
Creates a Duration from JulianYear.
public static Duration FromJulianYears(double julianyears)
Parameters
julianyearsdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromMicroseconds(double)
Creates a Duration from Microsecond.
public static Duration FromMicroseconds(double microseconds)
Parameters
microsecondsdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromMilliseconds(double)
Creates a Duration from Millisecond.
public static Duration FromMilliseconds(double milliseconds)
Parameters
millisecondsdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromMinutes(double)
public static Duration FromMinutes(double minutes)
Parameters
minutesdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromMonths30(double)
public static Duration FromMonths30(double months30)
Parameters
months30double
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromNanoseconds(double)
Creates a Duration from Nanosecond.
public static Duration FromNanoseconds(double nanoseconds)
Parameters
nanosecondsdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromSeconds(double)
public static Duration FromSeconds(double seconds)
Parameters
secondsdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromSols(double)
public static Duration FromSols(double sols)
Parameters
solsdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromWeeks(double)
public static Duration FromWeeks(double weeks)
Parameters
weeksdouble
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromYears365(double)
public static Duration FromYears365(double years365)
Parameters
years365double
Returns
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
unitDurationUnit
Returns
- Duration
A Duration with the specified unit.