Struct ConsensusTimeStamp
Represents a consensus timestamp value to the resolution of nanoseconds.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
[JsonConverter(typeof(ConsensusTimeStampConverter))]
public readonly record struct ConsensusTimeStamp : IComparable<ConsensusTimeStamp>, IComparable, IEquatable<ConsensusTimeStamp>
Constructors
| Edit this page View SourceConsensusTimeStamp()
Default Constructor, represents the minimum allowed time.
Declaration
public ConsensusTimeStamp()
ConsensusTimeStamp(DateTime)
Constructor taking a .net DateTime object
Declaration
public ConsensusTimeStamp(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | The DateTime representing the moment in time this consensus timestamp will represent. |
ConsensusTimeStamp(decimal)
Constructor taking the number of seconds since the unix epoch.
Declaration
public ConsensusTimeStamp(decimal seconds)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | seconds | The fractional number of seconds since the unix epoch. |
ConsensusTimeStamp(long, int)
Constructor taking the number of whole seconds and nano seconds since the unix epoch.
Declaration
public ConsensusTimeStamp(long seconds, int nanos)
Parameters
| Type | Name | Description |
|---|---|---|
| long | seconds | Number of complete seconds since the start of the epoch |
| int | nanos | Number of nanoseconds since the start of the last second |
Fields
| Edit this page View SourceMaxValue
The maximum possible time value.
Declaration
public static readonly ConsensusTimeStamp MaxValue
Field Value
| Type | Description |
|---|---|
| ConsensusTimeStamp |
MinValue
The minimum possible time value.
Declaration
public static readonly ConsensusTimeStamp MinValue
Field Value
| Type | Description |
|---|---|
| ConsensusTimeStamp |
Properties
| Edit this page View SourceNow
A consensus time stamp representing the current time.
Declaration
public static ConsensusTimeStamp Now { get; }
Property Value
| Type | Description |
|---|---|
| ConsensusTimeStamp |
Seconds
The number of decimal seconds since the unix epoch.
Declaration
public decimal Seconds { get; }
Property Value
| Type | Description |
|---|---|
| decimal |
Methods
| Edit this page View SourceCompareTo(ConsensusTimeStamp)
Compares the current consensus time instance with another consensus time instance.
Declaration
public int CompareTo(ConsensusTimeStamp other)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusTimeStamp | other | The other consensus time stamp to compare against. |
Returns
| Type | Description |
|---|---|
| int | Less than zero if this instance represents an earlier time than the other timestamp, zero if the same and greater than zero if it is later. |
CompareTo(object?)
Compares the current consensus time instance with another object that may be a consensus time instance.
Declaration
public int CompareTo(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The other object to compare against. |
Returns
| Type | Description |
|---|---|
| int | Less than zero if this instance represents an earlier time than the other timestamp, zero if the same and greater than zero if it is later. |
ToString()
Produces a string representing the consensus time stamp in the HAPI string form 00000.000000000.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | HAPI string form of the date. |
Overrides
Operators
| Edit this page View Sourceoperator >(ConsensusTimeStamp, ConsensusTimeStamp)
Compares the two consensus time stamps, returns true if the lhs value comes after the rhs value.
Declaration
public static bool operator >(ConsensusTimeStamp lhs, ConsensusTimeStamp rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusTimeStamp | lhs | The Consensus Time Stamp Left hand side of the operator. |
| ConsensusTimeStamp | rhs | The Consensus Time Stamp Right hand side of the operator. |
Returns
| Type | Description |
|---|---|
| bool | True if the lhs value comes after the rhs value, otherwise false. |
operator >=(ConsensusTimeStamp, ConsensusTimeStamp)
Compares the two consensus time stamps, returns true if the t1 value is equal to or later in time than the t2 value.
Declaration
public static bool operator >=(ConsensusTimeStamp t1, ConsensusTimeStamp t2)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusTimeStamp | t1 | The Consensus Time Stamp Left hand side of the operator. |
| ConsensusTimeStamp | t2 | The Consensus Time Stamp Right hand side of the operator. |
Returns
| Type | Description |
|---|---|
| bool | True if the t1 value equals or comes after the t2 value, otherwise false. |
implicit operator ConsensusTimeStamp(DateTime)
Implicit helper cast to convert an existing .net DateTime object into a ConsensusTimeStamp
Declaration
public static implicit operator ConsensusTimeStamp(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | The DateTime object representing the time. |
Returns
| Type | Description |
|---|---|
| ConsensusTimeStamp |
operator <(ConsensusTimeStamp, ConsensusTimeStamp)
Compares the two consensus time stamps, returns true if the lhs value is earlier in time than the rhs value.
Declaration
public static bool operator <(ConsensusTimeStamp lhs, ConsensusTimeStamp rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusTimeStamp | lhs | The Consensus Time Stamp Left hand side of the operator. |
| ConsensusTimeStamp | rhs | The Consensus Time Stamp Right hand side of the operator. |
Returns
| Type | Description |
|---|---|
| bool | True if the lhs value represents an earlier time than the rhs value. |
operator <=(ConsensusTimeStamp, ConsensusTimeStamp)
Compares the two consensus time stamps, returns true if the lhs value is equal to or earlier in time than the rhs value.
Declaration
public static bool operator <=(ConsensusTimeStamp lhs, ConsensusTimeStamp rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusTimeStamp | lhs | The Consensus Time Stamp Left hand side of the operator. |
| ConsensusTimeStamp | rhs | The Consensus Time Stamp Right hand side of the operator. |
Returns
| Type | Description |
|---|---|
| bool | True if the lhs value represents an equal or earlier time than the rhs value. |
operator -(ConsensusTimeStamp, ConsensusTimeStamp)
Computes the difference between two consensus timestamps, producing the decimal fraction of total seconds difference between the two.
Declaration
public static decimal operator -(ConsensusTimeStamp lhs, ConsensusTimeStamp rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsensusTimeStamp | lhs | The Consensus Time Stamp Left hand side of the operator. |
| ConsensusTimeStamp | rhs | The Consensus Time Stamp Right hand side of the operator. |
Returns
| Type | Description |
|---|---|
| decimal | The fractional number of seconds difference between the two consensus time stamps. |