TimePoint struct
Wall-clock instant: nanoseconds since the Unix epoch (UTC). Instants stamped on
different hosts are only as comparable as those hosts' clocks are synchronized.
Converts to a UTC DateTime implicitly or with TimePoint.ToDateTime,
truncated to its 100 ns tick.
Namespace: Quaternar.Qaros · Assembly: Quaternar.Qaros.dll · Source: QarTypes.cs
public readonly struct TimePoint : IEquatable<TimePoint>, IComparable<TimePoint>
Implements: IEquatable<TimePoint>, IComparable<TimePoint>
Constructors
TimePoint(long)
public TimePoint(long unixNanoseconds)
Parameters
| Name | Type | Description |
|---|---|---|
unixNanoseconds | long |
Properties
UnixNanoseconds
Nanoseconds since 1970-01-01T00:00:00Z.
public long UnixNanoseconds { get; }
Value: long
Methods
| Member | Description |
|---|---|
| ToDateTime() | The instant as a UTC DateTime, truncated to its 100 ns tick. |
| ToDateTimeOffset() | The instant as a DateTimeOffset at UTC, truncated to its 100 ns tick. |
| FromDateTime(DateTime) | From a DateTime; a local or unspecified kind is converted to UTC first. |
| FromDateTimeOffset(DateTimeOffset) | |
| Equals(TimePoint) | Indicates whether the current object is equal to another object of the same type. |
| Equals(object?) | Indicates whether this instance and a specified object are equal. |
| GetHashCode() | Returns the hash code for this instance. |
| CompareTo(TimePoint) | Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. |
| ToString() | Returns the fully qualified type name of this instance. |
ToDateTime
The instant as a UTC DateTime, truncated to its 100 ns tick.
public DateTime ToDateTime()
Returns: DateTime
ToDateTimeOffset
The instant as a DateTimeOffset at UTC, truncated to its 100 ns tick.
public DateTimeOffset ToDateTimeOffset()
Returns: DateTimeOffset
FromDateTime
From a DateTime; a local or unspecified kind is converted to UTC first.
public static TimePoint FromDateTime(DateTime value)
Parameters
| Name | Type | Description |
|---|---|---|
value | DateTime |
Returns: TimePoint
FromDateTimeOffset
public static TimePoint FromDateTimeOffset(DateTimeOffset value)
Parameters
| Name | Type | Description |
|---|---|---|
value | DateTimeOffset |
Returns: TimePoint
Equals(TimePoint)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(TimePoint other)
Parameters
| Name | Type | Description |
|---|---|---|
other | TimePoint | An object to compare with this object. |
Returns: bool — true if the current object is equal to the other parameter; otherwise, false.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
| Name | Type | Description |
|---|---|---|
obj | object | The object to compare with the current instance. |
Returns: bool — true if obj and this instance are the same type and represent the same value; otherwise, false.
GetHashCode
Returns the hash code for this instance.
public override int GetHashCode()
Returns: int — A 32-bit signed integer that is the hash code for this instance.
CompareTo
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(TimePoint other)
Parameters
| Name | Type | Description |
|---|---|---|
other | TimePoint | An object to compare with this instance. |
Returns: int — A value that indicates the relative order of the objects being compared. The return value has these meanings:
| Value | Meaning |
|---|---|
| Less than zero | This instance precedes `other` in the sort order. |
| Zero | This instance occurs in the same position in the sort order as `other`. |
| Greater than zero | This instance follows `other` in the sort order. |
ToString
Returns the fully qualified type name of this instance.
public override string ToString()
Returns: string — The fully qualified type name.
Operators
implicit operator DateTime
public static implicit operator DateTime(TimePoint value)
Parameters
| Name | Type | Description |
|---|---|---|
value | TimePoint |
Returns: DateTime
operator -
public static TimeSpan operator -(TimePoint left, TimePoint right)
Parameters
| Name | Type | Description |
|---|---|---|
left | TimePoint | |
right | TimePoint |
Returns: TimeSpan
operator +
public static TimePoint operator +(TimePoint value, TimeSpan offset)
Parameters
| Name | Type | Description |
|---|---|---|
value | TimePoint | |
offset | TimeSpan |
Returns: TimePoint
operator ==
public static bool operator ==(TimePoint left, TimePoint right)
Parameters
| Name | Type | Description |
|---|---|---|
left | TimePoint | |
right | TimePoint |
Returns: bool
operator !=
public static bool operator !=(TimePoint left, TimePoint right)
Parameters
| Name | Type | Description |
|---|---|---|
left | TimePoint | |
right | TimePoint |
Returns: bool
operator <
public static bool operator <(TimePoint left, TimePoint right)
Parameters
| Name | Type | Description |
|---|---|---|
left | TimePoint | |
right | TimePoint |
Returns: bool
operator >
public static bool operator >(TimePoint left, TimePoint right)
Parameters
| Name | Type | Description |
|---|---|---|
left | TimePoint | |
right | TimePoint |
Returns: bool
operator <=
public static bool operator <=(TimePoint left, TimePoint right)
Parameters
| Name | Type | Description |
|---|---|---|
left | TimePoint | |
right | TimePoint |
Returns: bool
operator >=
public static bool operator >=(TimePoint left, TimePoint right)
Parameters
| Name | Type | Description |
|---|---|---|
left | TimePoint | |
right | TimePoint |
Returns: bool