TimeOffset Struct
Represents an amount of time.
public struct TimeOffset : IComparable<TimeOffset>, IEquatable<TimeOffset>, IFormattable
Public Structure TimeOffset
Implements IComparable(Of TimeOffset), IEquatable(Of TimeOffset), IFormattable
Properties
DefaultUnit
Gets or sets the default time unit that is applied globally every time TimeOffset is converted from/to a System.Double.
public static TimeOffsetUnit DefaultUnit { get; set; }
Public Shared Property DefaultUnit As TimeOffsetUnit
Property Value
The default time unit.
Remarks
Initial value is Millisecond.
This property makes code less verbose and, thus, easier to read and maintain because instead of using From(Double, TimeOffsetUnit) and To(TimeOffsetUnit), one can use implicit conversions from/to a System.Double.
Since default time unit is applied globally (like any other static member), it is advisable not to set DefaultUnit property or use implicit conversions from/to a System.Double if GemBox.Presentation is used by various application functions that expect different default time unit, especially if usage is multi-threaded.
Unit
Gets the unit.
Property Value
The unit.
Value
Gets the value.
Property Value
- System.Double
The value.
Methods
CompareTo(TimeOffset)
Compares the value of this instance to a specified TimeOffset value and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified TimeOffset value.
public int CompareTo(TimeOffset other)
Public Function CompareTo(other As TimeOffset) As Integer
Parameters
other
- TimeOffset
The object to compare to the current instance.
Returns
- System.Int32
A signed number indicating the relative values of this instance and the other
parameter.
If returned value is less than zero, then this instance is earlier than other
; else, if it is zero, then this instance is the same as other
; else (if it is greater than zero) this instance is later than other
.
Equals(TimeOffset)
Determines whether the other
TimeOffset is equal to this TimeOffset instance.
Parameters
other
- TimeOffset
The other time offset to compare with this time offset instance.
Returns
- System.Boolean
true if the other
TimeOffset is equal to this TimeOffset instance; otherwise, false.
Equals(Object)
Determines whether the specified System.Object is equal to this TimeOffset instance.
public override bool Equals(object obj)
Public Overrides Function Equals(obj As Object) As Boolean
Parameters
obj
- System.Object
The System.Object to compare with this time offset instance.
Returns
- System.Boolean
true if the specified System.Object is a TimeOffset and is equal to this TimeOffset instance; otherwise, false.
Overrides
From(Double, TimeOffsetUnit)
Converts a time amount value in a specified time unit to a TimeOffset instance.
Negative value
is automatically coerced to zero.
public static TimeOffset From(double value, TimeOffsetUnit unit)
Public Shared Function From(value As Double, unit As TimeOffsetUnit) As TimeOffset
Parameters
value
- System.Double
The time amount value.
unit
- TimeOffsetUnit
The time unit.
Returns
A TimeOffset instance that is equivalent to a specified input time amount in a specified time unit.
GetHashCode()
Returns a hash code for this TimeOffset instance.
Returns
- System.Int32
An integer value that specifies a hash value for this TimeOffset instance.
Overrides
To(TimeOffsetUnit)
Converts this TimeOffset instance to an another TimeOffset instance with the specified time unit.
public TimeOffset To(TimeOffsetUnit unit)
Public Function To(unit As TimeOffsetUnit) As TimeOffset
Parameters
unit
- TimeOffsetUnit
The time unit.
Returns
A TimeOffset instance that is equivalent to this TimeOffset instance in a specified time unit.
ToString()
Returns a System.String that represents this TimeOffset instance.
Returns
- System.String
A System.String that represents this TimeOffset instance.
Overrides
ToString(String, IFormatProvider)
Returns a System.String that represents this TimeOffset instance in a specified format by using a specified format provider.
public string ToString(string format, IFormatProvider formatProvider)
Public Function ToString(format As String, formatProvider As IFormatProvider) As String
Parameters
format
- System.String
The format.
formatProvider
- System.IFormatProvider
The format provider.
Returns
- System.String
A System.String that represents this TimeOffset instance in a specified format by using a specified format provider.
Operators
Equality(TimeOffset, TimeOffset)
Determines whether first
and second
TimeOffsets are equal.
public static bool operator ==(TimeOffset first, TimeOffset second)
Public Shared Operator =(first As TimeOffset, second As TimeOffset) As Boolean
Parameters
first
- TimeOffset
The first time offset.
second
- TimeOffset
The second time offset.
Returns
- System.Boolean
true if first
and second
time offsets are equal; otherwise, false.
GreaterThan(TimeOffset, TimeOffset)
Determines whether first
TimeOffset is later than second
TimeOffset.
public static bool operator>(TimeOffset first, TimeOffset second)
Public Shared Operator>(first As TimeOffset, second As TimeOffset) As Boolean
Parameters
first
- TimeOffset
The first time offset.
second
- TimeOffset
The second time offset.
Returns
- System.Boolean
true if first
time offset is later than second
time offset; otherwise, false.
GreaterThanOrEqual(TimeOffset, TimeOffset)
Determines whether first
TimeOffset is later than or equal to second
TimeOffset.
public static bool operator >=(TimeOffset first, TimeOffset second)
Public Shared Operator >=(first As TimeOffset, second As TimeOffset) As Boolean
Parameters
first
- TimeOffset
The first time offset.
second
- TimeOffset
The second time offset.
Returns
- System.Boolean
true if first
time offset is later than or equal to second
time offset; otherwise, false.
Implicit(TimeOffset to Double)
Converts a TimeOffset instance to a time amount value in a DefaultUnit.
public static implicit operator double (TimeOffset value)
Public Shared Widening Operator CType(value As TimeOffset) As Double
Parameters
value
- TimeOffset
The time offset value.
Returns
- System.Double
A time amount value that is equivalent to a specified input TimeOffset instance in a DefaultUnit.
Implicit(Double to TimeOffset)
Converts a time amount value in a DefaultUnit to a TimeOffset instance.
public static implicit operator TimeOffset(double value)
Public Shared Widening Operator CType(value As Double) As TimeOffset
Parameters
value
- System.Double
The time amount value.
Returns
A TimeOffset instance that is equivalent to a specified input time amount in a DefaultUnit.
Inequality(TimeOffset, TimeOffset)
Determines whether first
and second
TimeOffsets are not equal.
public static bool operator !=(TimeOffset first, TimeOffset second)
Public Shared Operator <>(first As TimeOffset, second As TimeOffset) As Boolean
Parameters
first
- TimeOffset
The first time offset.
second
- TimeOffset
The second time offset.
Returns
- System.Boolean
true if first
and second
time offsets are not equal; otherwise, false.
LessThan(TimeOffset, TimeOffset)
Determines whether first
TimeOffset is earlier than second
TimeOffset.
public static bool operator <(TimeOffset first, TimeOffset second)
Public Shared Operator <(first As TimeOffset, second As TimeOffset) As Boolean
Parameters
first
- TimeOffset
The first time offset.
second
- TimeOffset
The second time offset.
Returns
- System.Boolean
true if first
time offset is earlier than second
time offset; otherwise, false.
LessThanOrEqual(TimeOffset, TimeOffset)
Determines whether first
TimeOffset is earlier than or equal to second
TimeOffset.
public static bool operator <=(TimeOffset first, TimeOffset second)
Public Shared Operator <=(first As TimeOffset, second As TimeOffset) As Boolean
Parameters
first
- TimeOffset
The first time offset.
second
- TimeOffset
The second time offset.
Returns
- System.Boolean
true if first
time offset is earlier than or equal to second
time offset; otherwise, false.