Skip to main content
Version: 0.9.0 (next)

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

public readonly struct TimePoint : IEquatable<TimePoint>, IComparable<TimePoint>

Implements: IEquatable<TimePoint>, IComparable<TimePoint>

Constructors​

TimePoint(long)​

public TimePoint(long unixNanoseconds)

Parameters

NameTypeDescription
unixNanosecondslong

Properties​

UnixNanoseconds​

Nanoseconds since 1970-01-01T00:00:00Z.

public long UnixNanoseconds { get; }

Value: long

Methods​

MemberDescription
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

NameTypeDescription
valueDateTime

Returns: TimePoint

FromDateTimeOffset​

public static TimePoint FromDateTimeOffset(DateTimeOffset value)

Parameters

NameTypeDescription
valueDateTimeOffset

Returns: TimePoint

Equals(TimePoint)​

Indicates whether the current object is equal to another object of the same type.

public bool Equals(TimePoint other)

Parameters

NameTypeDescription
otherTimePointAn 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

NameTypeDescription
objobjectThe 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

NameTypeDescription
otherTimePointAn 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​

MemberDescription
implicit operator DateTime(TimePoint)
operator -(TimePoint, TimePoint)
operator +(TimePoint, TimeSpan)
operator ==(TimePoint, TimePoint)
operator !=(TimePoint, TimePoint)
operator <(TimePoint, TimePoint)
operator >(TimePoint, TimePoint)
operator <=(TimePoint, TimePoint)
operator >=(TimePoint, TimePoint)

implicit operator DateTime​

public static implicit operator DateTime(TimePoint value)

Parameters

NameTypeDescription
valueTimePoint

Returns: DateTime

operator -​

public static TimeSpan operator -(TimePoint left, TimePoint right)

Parameters

NameTypeDescription
leftTimePoint
rightTimePoint

Returns: TimeSpan

operator +​

public static TimePoint operator +(TimePoint value, TimeSpan offset)

Parameters

NameTypeDescription
valueTimePoint
offsetTimeSpan

Returns: TimePoint

operator ==​

public static bool operator ==(TimePoint left, TimePoint right)

Parameters

NameTypeDescription
leftTimePoint
rightTimePoint

Returns: bool

operator !=​

public static bool operator !=(TimePoint left, TimePoint right)

Parameters

NameTypeDescription
leftTimePoint
rightTimePoint

Returns: bool

operator <​

public static bool operator <(TimePoint left, TimePoint right)

Parameters

NameTypeDescription
leftTimePoint
rightTimePoint

Returns: bool

operator >​

public static bool operator >(TimePoint left, TimePoint right)

Parameters

NameTypeDescription
leftTimePoint
rightTimePoint

Returns: bool

operator <=​

public static bool operator <=(TimePoint left, TimePoint right)

Parameters

NameTypeDescription
leftTimePoint
rightTimePoint

Returns: bool

operator >=​

public static bool operator >=(TimePoint left, TimePoint right)

Parameters

NameTypeDescription
leftTimePoint
rightTimePoint

Returns: bool