Show / Hide Table of Contents

Struct ConsensusTimeStamp

Represents a consensus timestamp value to the resolution of nanoseconds.

Implements
IComparable<ConsensusTimeStamp>
IComparable
IEquatable<ConsensusTimeStamp>
Inherited Members
ValueType.Equals(object)
ValueType.GetHashCode()
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: Hiero
Assembly: Hiero.dll
Syntax
[JsonConverter(typeof(ConsensusTimeStampConverter))]
public readonly record struct ConsensusTimeStamp : IComparable<ConsensusTimeStamp>, IComparable, IEquatable<ConsensusTimeStamp>

Constructors

| Edit this page View Source

ConsensusTimeStamp()

Default Constructor, represents the minimum allowed time.

Declaration
public ConsensusTimeStamp()
| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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 Source

MaxValue

The maximum possible time value.

Declaration
public static readonly ConsensusTimeStamp MaxValue
Field Value
Type Description
ConsensusTimeStamp
| Edit this page View Source

MinValue

The minimum possible time value.

Declaration
public static readonly ConsensusTimeStamp MinValue
Field Value
Type Description
ConsensusTimeStamp

Properties

| Edit this page View Source

Now

A consensus time stamp representing the current time.

Declaration
public static ConsensusTimeStamp Now { get; }
Property Value
Type Description
ConsensusTimeStamp
| Edit this page View Source

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 Source

CompareTo(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.

| Edit this page View Source

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.

| Edit this page View Source

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
ValueType.ToString()

Operators

| Edit this page View Source

operator >(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.

| Edit this page View Source

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.

| Edit this page View Source

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
| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

Implements

IComparable<T>
IComparable
IEquatable<T>
  • Edit this page
  • View Source
In this article
Back to top .NET Client Library for Hiero Network and Hedera Hashgraph