Click or drag to resize

Time Structure

Represents a time measurement, in seconds, as a double-precision floating-point number.
Inheritance Hierarchy
SystemObject
  SystemValueType
    GSF.UnitsTime

Namespace: GSF.Units
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.181-beta
Syntax
View Source

The Time type exposes the following members.

Constructors
 NameDescription
Public methodTime(Double) Creates a new Time.
Public methodTime(TimeSpan) Creates a new Time.
Top
Methods
 NameDescription
Public methodCompareTo(Double) Compares this instance to a specified Double and returns an indication of their relative values.
Public methodCompareTo(Object) Compares this instance to a specified object and returns an indication of their relative values.
Public methodCompareTo(Time) Compares this instance to a specified Time and returns an indication of their relative values.
Public methodCompareTo(TimeSpan) Compares this instance to a specified TimeSpan and returns an indication of their relative values.
Public methodStatic memberConvertFrom Converts the value in the specified sourceUnit to a new Time in seconds.
Public methodConvertTo Converts the Time to the specified targetUnit.
Public methodEquals(Double) Returns a value indicating whether this instance is equal to a specified Double value.
Public methodEquals(Object) Returns a value indicating whether this instance is equal to a specified object.
(Overrides ValueTypeEquals(Object))
Public methodEquals(Time) Returns a value indicating whether this instance is equal to a specified Time value.
Public methodEquals(TimeSpan) Returns a value indicating whether this instance is equal to a specified TimeSpan value.
Public methodStatic memberFromAtomicUnitsOfTime Creates a new Time value from the specified value in atomic units of time.
Public methodStatic memberFromDays Creates a new Time value from the specified value in days.
Public methodStatic memberFromHours Creates a new Time value from the specified value in hours.
Public methodStatic memberFromKe Creates a new Time value from the specified value in ke, the traditional Chinese unit of decimal time.
Public methodStatic memberFromMinutes Creates a new Time value from the specified value in minutes.
Public methodStatic memberFromPlanckTime Creates a new Time value from the specified value in Planck time.
Public methodStatic memberFromTicks Creates a new Time value from the specified value in Ticks.
Public methodStatic memberFromWeeks Creates a new Time value from the specified value in weeks.
Public methodGetHashCode Returns the hash code for this instance.
(Overrides ValueTypeGetHashCode)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodGetTypeCode Returns the TypeCode for value type Double.
Public methodStatic memberParse(String) Converts the string representation of a number to its Time equivalent.
Public methodStatic memberParse(String, NumberStyles) Converts the string representation of a number in a specified style to its Time equivalent.
Public methodStatic memberParse(String, IFormatProvider) Converts the string representation of a number in a specified culture-specific format to its Time equivalent.
Public methodStatic memberParse(String, NumberStyles, IFormatProvider) Converts the string representation of a number in a specified style and culture-specific format to its Time equivalent.
Public methodStatic memberSecondsPerMonth Returns the number of seconds in the specified month and year.
Public methodStatic memberSecondsPerYear Returns the number of seconds in the specified year.
Public methodToAtomicUnitsOfTime Gets the Time value in atomic units of time.
Public methodToDays Gets the Time value in days.
Public methodStatic memberToElapsedTimeString Converts total seconds into a textual representation of years, days, hours, minutes and seconds with the specified number of fractional digits given string array of time names.
Public methodToHours Gets the Time value in hours.
Public methodToKe Gets the Time value in ke, the traditional Chinese unit of decimal time.
Public methodToMinutes Gets the Time value in minutes.
Public methodToPlanckTime Gets the Time value in Planck time.
Public methodToString Converts the Time value into a textual representation of years, days, hours, minutes and seconds.
(Overrides ValueTypeToString)
Public methodToString(IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
Public methodToString(String) Converts the numeric value of this instance to its equivalent string representation, using the specified format.
Public methodToString(Int32, Double) Converts the Time value into a textual representation of years, days, hours, minutes and seconds with the specified number of fractional digits.
Public methodToString(String, IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
Public methodToString(Int32, String, Double) Converts the Time value into a textual representation of years, days, hours, minutes and seconds with the specified number of fractional digits given string array of time names.
Public methodToTicks Converts the Time value, in seconds, to 100-nanosecond tick intervals.
Public methodToWeeks Gets the Time value in weeks.
Public methodStatic memberTryParse(String, Time) Converts the string representation of a number to its Time equivalent. A return value indicates whether the conversion succeeded or failed.
Public methodStatic memberTryParse(String, NumberStyles, IFormatProvider, Time) Converts the string representation of a number in a specified style and culture-specific format to its Time equivalent. A return value indicates whether the conversion succeeded or failed.
Top
Operators
 NameDescription
Public operatorStatic memberAddition(Time, Time) Returns computed sum of values.
Public operatorStatic memberDivision(Time, Time) Returns computed division of values.
Public operatorStatic memberEquality(Time, Time) Compares the two values for equality.
Public operatorStatic memberExponent(Time, Time) Returns result of first value raised to power of second value.
Public operatorStatic memberGreaterThan(Time, Time) Returns true if left value is greater than right value.
Public operatorStatic memberGreaterThanOrEqual(Time, Time) Returns true if left value is greater than or equal to right value.
Public operatorStatic member(Double to Time) Implicitly converts value, represented in seconds, to a Time.
Public operatorStatic member(Time to Double) Implicitly converts Time, represented in seconds, to a Double.
Public operatorStatic member(Time to TimeSpan) Implicitly converts Time, represented in seconds, to a TimeSpan.
Public operatorStatic member(TimeSpan to Time) Implicitly converts value, represented as a TimeSpan, to a Time.
Public operatorStatic memberInequality(Time, Time) Compares the two values for inequality.
Public operatorStatic memberLessThan(Time, Time) Returns true if left value is less than right value.
Public operatorStatic memberLessThanOrEqual(Time, Time) Returns true if left value is less or equal to than right value.
Public operatorStatic memberModulus(Time, Time) Returns computed remainder after dividing first value by the second.
Public operatorStatic memberMultiply(Time, Time) Returns computed product of values.
Public operatorStatic memberSubtraction(Time, Time) Returns computed difference of values.
Top
Fields
 NameDescription
Public fieldStatic memberMaxValueRepresents the largest possible value of a Time. This field is constant.
Public fieldStatic memberMinValueRepresents the smallest possible value of a Time. This field is constant.
Public fieldStatic memberSecondsPerDay Number of seconds in one day.
Public fieldStatic memberSecondsPerHour Number of seconds in one hour.
Public fieldStatic memberSecondsPerMinute Number of seconds in one minute.
Public fieldStatic memberSecondsPerTick Fractional number of seconds in one tick.
Public fieldStatic memberSecondsPerWeek Number of seconds in one week.
Public fieldStatic memberTimeNames Standard time names used by ToElapsedTimeString(Double, Int32, String, Double) method.
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Remarks
This class behaves just like a Double representing a time in seconds; it is implicitly castable to and from a Double and therefore can be generally used "as" a double, but it has the advantage of handling conversions to and from other time representations, specifically minutes, hours, days, weeks, atomic units of time, Planck time and ke. Metric conversions are handled simply by applying the needed SI conversion factor, for example:
Example
Convert time in nanoseconds to seconds:
C#
public Time GetSeconds(double nanoseconds)
{
    return nanoseconds * SI.Nano;
}
Convert time in seconds to milliseconds:
C#
public double GetMilliseconds(Time seconds)
{
    return time / SI.Milli;
}
This example converts minutes to hours:
C#
public double GetHours(double minutes)
{
    return Time.FromMinutes(minutes).ToHours();
}

Note that the ToString method will convert the Time value, in seconds, into a textual representation of years, days, hours, minutes and seconds using the static function ToElapsedTimeString(Double, Int32, String, Double).

See Also