Time Structure

Represents a time measurement, in seconds, as a double-precision floating-point number.

Definition

Namespace: Gemstone.Units
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.128 -- Release Build+d050cfc5563c89a1188cc3c6b2d417530856f490
[SerializableAttribute]
public struct Time : IComparable, IFormattable, 
	IConvertible, IComparable<Time>, IComparable<TimeSpan>, 
	IComparable<double>, IEquatable<Time>, IEquatable<TimeSpan>, 
	IEquatable<double>
Inheritance
Object    ValueType    Time
Implements
IComparable, IComparableTime, IComparableTimeSpan, IComparableDouble, IConvertible, IEquatableTime, IEquatableTimeSpan, IEquatableDouble, IFormattable

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).

Constructors

Time(Double) Creates a new Time.
Time(TimeSpan) Creates a new Time.

Methods

CompareTo(Double) Compares this instance to a specified Double and returns an indication of their relative values.
CompareTo(Object) Compares this instance to a specified object and returns an indication of their relative values.
CompareTo(Time) Compares this instance to a specified Time and returns an indication of their relative values.
CompareTo(TimeSpan) Compares this instance to a specified TimeSpan and returns an indication of their relative values.
ConvertFrom Converts the value in the specified sourceUnit to a new Time in seconds.
ConvertTo Converts the Time to the specified targetUnit.
Equals(Double) Returns a value indicating whether this instance is equal to a specified Double value.
Equals(Object) Returns a value indicating whether this instance is equal to a specified object.
(Overrides ValueTypeEquals(Object))
Equals(Time) Returns a value indicating whether this instance is equal to a specified Time value.
Equals(TimeSpan) Returns a value indicating whether this instance is equal to a specified TimeSpan value.
FromAtomicUnitsOfTime Creates a new Time value from the specified value in atomic units of time.
FromDays Creates a new Time value from the specified value in days.
FromHours Creates a new Time value from the specified value in hours.
FromKe Creates a new Time value from the specified value in ke, the traditional Chinese unit of decimal time.
FromMinutes Creates a new Time value from the specified value in minutes.
FromPlanckTime Creates a new Time value from the specified value in Planck time.
FromTicks Creates a new Time value from the specified value in Ticks.
FromWeeks Creates a new Time value from the specified value in weeks.
GetHashCode Returns the hash code for this instance.
(Overrides ValueTypeGetHashCode)
GetTypeGets the Type of the current instance.
(Inherited from Object)
GetTypeCode Returns the TypeCode for value type Double.
Parse(String) Converts the string representation of a number to its Time equivalent.
Parse(String, NumberStyles) Converts the string representation of a number in a specified style to its Time equivalent.
Parse(String, IFormatProvider) Converts the string representation of a number in a specified culture-specific format to its Time equivalent.
Parse(String, NumberStyles, IFormatProvider) Converts the string representation of a number in a specified style and culture-specific format to its Time equivalent.
SecondsPerMonth Returns the number of seconds in the specified month and year.
SecondsPerYear Returns the number of seconds in the specified year.
ToAtomicUnitsOfTime Gets the Time value in atomic units of time.
ToDays Gets the Time value in days.
ToElapsedTimeString 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.
ToHours Gets the Time value in hours.
ToKe Gets the Time value in ke, the traditional Chinese unit of decimal time.
ToMinutes Gets the Time value in minutes.
ToPlanckTime Gets the Time value in Planck time.
ToString Converts the Time value into a textual representation of years, days, hours, minutes and seconds.
(Overrides ValueTypeToString)
ToString(IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
ToString(String) Converts the numeric value of this instance to its equivalent string representation, using the specified format.
ToString(Int32, Double) Converts the Time value into a textual representation of years, days, hours, minutes and seconds with the specified number of fractional digits.
ToString(String, IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
ToString(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.
ToTicks Converts the Time value, in seconds, to 100-nanosecond tick intervals.
ToWeeks Gets the Time value in weeks.
TryParse(String, Time) Converts the string representation of a number to its Time equivalent. A return value indicates whether the conversion succeeded or failed.
TryParse(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.

Operators

Addition(Time, Time) Returns computed sum of values.
Division(Time, Time) Returns computed division of values.
Equality(Time, Time) Compares the two values for equality.
Exponent(Time, Time) Returns result of first value raised to power of second value.
GreaterThan(Time, Time) Returns true if left value is greater than right value.
GreaterThanOrEqual(Time, Time) Returns true if left value is greater than or equal to right value.
(Double to Time) Implicitly converts value, represented in seconds, to a Time.
(Time to Double) Implicitly converts Time, represented in seconds, to a Double.
(Time to TimeSpan) Implicitly converts Time, represented in seconds, to a TimeSpan.
(TimeSpan to Time) Implicitly converts value, represented as a TimeSpan, to a Time.
Inequality(Time, Time) Compares the two values for inequality.
LessThan(Time, Time) Returns true if left value is less than right value.
LessThanOrEqual(Time, Time) Returns true if left value is less or equal to than right value.
Modulus(Time, Time) Returns computed remainder after dividing first value by the second.
Multiply(Time, Time) Returns computed product of values.
Subtraction(Time, Time) Returns computed difference of values.

Fields

MaxValueRepresents the largest possible value of a Time. This field is constant.
MinValueRepresents the smallest possible value of a Time. This field is constant.
SecondsPerDay Number of seconds in one day.
SecondsPerHour Number of seconds in one hour.
SecondsPerMinute Number of seconds in one minute.
SecondsPerTick Fractional number of seconds in one tick.
SecondsPerWeek Number of seconds in one week.
TimeNames Standard time names used by ToElapsedTimeString(Double, Int32, String, Double) method.

Extension Methods

GetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
GetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)

See Also