Struct Timestamp
Represents a number of elapsed ticks since UnixEpoch.
public readonly struct Timestamp : IEquatable<Timestamp>, IComparable<Timestamp>, IComparable
- Implements
- Inherited Members
Constructors
Timestamp(DateTime)
Creates a new Timestamp instance.
public Timestamp(DateTime utcValue)
Parameters
utcValue
DateTimeSource date time.
Timestamp(long)
Creates a new Timestamp instance.
public Timestamp(long unixEpochTicks)
Parameters
Fields
Zero
Represents the UnixEpoch.
public static readonly Timestamp Zero
Field Value
Properties
UnixEpochTicks
Number of ticks elapsed since UnixEpoch.
public long UnixEpochTicks { get; }
Property Value
UtcValue
public DateTime UtcValue { get; }
Property Value
Methods
Add(Duration)
Creates a new Timestamp instance by adding value
to this instance.
[Pure]
public Timestamp Add(Duration value)
Parameters
Returns
CompareTo(Timestamp)
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.
[Pure]
public int CompareTo(Timestamp other)
Parameters
other
TimestampAn 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.
CompareTo(object?)
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.
[Pure]
public int CompareTo(object? obj)
Parameters
obj
objectAn 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 obj
in the sort order.Zero This instance occurs in the same position in the sort order as obj
.Greater than zero This instance follows obj
in the sort order.
Exceptions
- ArgumentException
obj
is not the same type as this instance.
Equals(Timestamp)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(Timestamp other)
Parameters
other
TimestampAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
[Pure]
public override bool Equals(object? obj)
Parameters
obj
objectThe 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.
[Pure]
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Subtract(Duration)
Creates a new Timestamp instance by subtracting value
from this instance.
[Pure]
public Timestamp Subtract(Duration value)
Parameters
Returns
Subtract(Timestamp)
Calculates a difference between this instance and the other
instance,
where this instance is treated as the end of the range.
[Pure]
public Duration Subtract(Timestamp other)
Parameters
other
TimestampInstance to subtract.
Returns
ToString()
Returns a string representation of this Timestamp instance.
[Pure]
public override string ToString()
Returns
- string
String representation.
Operators
operator +(Timestamp, Duration)
Creates a new Timestamp instance by adding a
and b
together.
[Pure]
public static Timestamp operator +(Timestamp a, Duration b)
Parameters
Returns
operator ==(Timestamp, Timestamp)
Checks if a
is equal to b
.
[Pure]
public static bool operator ==(Timestamp a, Timestamp b)
Parameters
Returns
- bool
true when operands are equal, otherwise false.
explicit operator DateTime(Timestamp)
Converts the provided duration to DateTime.
[Pure]
public static explicit operator DateTime(Timestamp source)
Parameters
source
TimestampValue to convert.
Returns
operator >(Timestamp, Timestamp)
Checks if a
is greater than b
.
[Pure]
public static bool operator >(Timestamp a, Timestamp b)
Parameters
Returns
- bool
true when
a
is greater thanb
, otherwise false.
operator >=(Timestamp, Timestamp)
Checks if a
is greater than or equal to b
.
[Pure]
public static bool operator >=(Timestamp a, Timestamp b)
Parameters
Returns
- bool
true when
a
is greater than or equal tob
, otherwise false.
operator !=(Timestamp, Timestamp)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(Timestamp a, Timestamp b)
Parameters
Returns
- bool
true when operands are not equal, otherwise false.
operator <(Timestamp, Timestamp)
Checks if a
is less than b
.
[Pure]
public static bool operator <(Timestamp a, Timestamp b)
Parameters
Returns
- bool
true when
a
is less thanb
, otherwise false.
operator <=(Timestamp, Timestamp)
Checks if a
is less than or equal to b
.
[Pure]
public static bool operator <=(Timestamp a, Timestamp b)
Parameters
Returns
- bool
true when
a
is less than or equal tob
, otherwise false.
operator -(Timestamp, Duration)
Creates a new Timestamp instance by subtracting b
from a
.
[Pure]
public static Timestamp operator -(Timestamp a, Duration b)
Parameters
Returns
operator -(Timestamp, Timestamp)
Creates a new Duration instance by subtracting b
from a
.
[Pure]
public static Duration operator -(Timestamp a, Timestamp b)