Firebase.Firestore.Timestamp

A nanosecond-precision immutable timestamp.

Summary

When this is stored as part of a document in Firestore, it is truncated to the microsecond, towards the start of time.

A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time. It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By restricting to that range, we ensure that we can convert to and from RFC 3339 date strings.

Inheritance

Inherits from: IEquatable< Timestamp >, IComparable, IComparable< Timestamp >

Public functions

CompareTo(Timestamp other)
int
CompareTo(object obj)
int
Equals(object obj)
override bool
Equals(Timestamp other)
bool
GetHashCode()
override int
ToDateTime()
DateTime
Converts this timestamp to a DateTime with a kind of DateTimeKind.Utc.
ToDateTimeOffset()
DateTimeOffset
Converts this timestamp into a DateTimeOffset.
ToString()
override string

Public static functions

FromDateTime(DateTime dateTime)
Converts a DateTime to a Timestamp.
FromDateTimeOffset(DateTimeOffset dateTimeOffset)
Converts the given DateTimeOffset to a Timestamp
GetCurrentTimestamp()
Returns the current timestamp according to the system clock.
operator!=(Timestamp lhs, Timestamp rhs)
bool
Operator overload to compare two Timestamp values for inequality.
operator<(Timestamp lhs, Timestamp rhs)
bool
Compares two timestamps.
operator<=(Timestamp lhs, Timestamp rhs)
bool
Compares two timestamps.
operator==(Timestamp lhs, Timestamp rhs)
bool
Operator overload to compare two Timestamp values for equality.
operator>(Timestamp lhs, Timestamp rhs)
bool
Compares two timestamps.
operator>=(Timestamp lhs, Timestamp rhs)
bool
Compares two timestamps.

Public functions

CompareTo

int Firebase::Firestore::Timestamp::CompareTo(
  Timestamp other
)

CompareTo

int Firebase::Firestore::Timestamp::CompareTo(
  object obj
)

Equals

override bool Firebase::Firestore::Timestamp::Equals(
  object obj
)

Equals

bool Firebase::Firestore::Timestamp::Equals(
  Timestamp other
)

GetHashCode

override int Firebase::Firestore::Timestamp::GetHashCode()

ToDateTime

DateTime Firebase::Firestore::Timestamp::ToDateTime()

Converts this timestamp to a DateTime with a kind of DateTimeKind.Utc.

This can lose information as DateTime has a precision of a tick (100 nanoseconds). If the timestamp is not a precise number of ticks, it will be truncated towards the start of time.

Details
Returns
A DateTime representation of this timestamp.

ToDateTimeOffset

DateTimeOffset Firebase::Firestore::Timestamp::ToDateTimeOffset()

Converts this timestamp into a DateTimeOffset.

The resulting DateTimeOffset will always have an Offset of zero. If the timestamp is not a precise number of ticks, it will be truncated towards the start of time. DateTimeOffset value precisely on a second.

Details
Returns
This timestamp as a DateTimeOffset.

ToString

override string Firebase::Firestore::Timestamp::ToString()

Public static functions

FromDateTime

Timestamp Firebase::Firestore::Timestamp::FromDateTime(
  DateTime dateTime
)

Converts a DateTime to a Timestamp.

Details
Parameters
dateTime
The value to convert; its kind must be DateTimeKind.Utc.
Returns
A Timestamp representation of dateTime .

FromDateTimeOffset

Timestamp Firebase::Firestore::Timestamp::FromDateTimeOffset(
  DateTimeOffset dateTimeOffset
)

Converts the given DateTimeOffset to a Timestamp

The offset is taken into consideration when converting the value (so the same instant in time is represented) but is not a separate part of the resulting value. In other words, there is no round-trip operation that can retrieve the original DateTimeOffset.

Details
Parameters
dateTimeOffset
The date and time (with UTC offset) to convert to a timestamp.
Returns
The converted timestamp.

GetCurrentTimestamp

Timestamp Firebase::Firestore::Timestamp::GetCurrentTimestamp()

Returns the current timestamp according to the system clock.

The system time zone is irrelevant, as a timestamp represents an instant in time.

Details
Returns
The current timestamp according to the system clock.

operator!=

bool Firebase::Firestore::Timestamp::operator!=(
  Timestamp lhs,
  Timestamp rhs
)

Operator overload to compare two Timestamp values for inequality.

Details
Parameters
lhs
Left value to compare
rhs
Right value to compare
Returns
false if lhs is equal to rhs ; otherwise true.

operator<

bool Firebase::Firestore::Timestamp::operator<(
  Timestamp lhs,
  Timestamp rhs
)

Compares two timestamps.

Details
Parameters
lhs
The left timestamp to compare.
rhs
The right timestamp to compare.
Returns
true if lhs is strictly earlier than rhs ; otherwise false.

operator<=

bool Firebase::Firestore::Timestamp::operator<=(
  Timestamp lhs,
  Timestamp rhs
)

Compares two timestamps.

Details
Parameters
lhs
The left timestamp to compare.
rhs
The right timestamp to compare.
Returns
true if lhs is earlier than or equal to rhs ; otherwise false.

operator==

bool Firebase::Firestore::Timestamp::operator==(
  Timestamp lhs,
  Timestamp rhs
)

Operator overload to compare two Timestamp values for equality.

Details
Parameters
lhs
Left value to compare
rhs
Right value to compare
Returns
true if lhs is equal to rhs ; otherwise false.

operator>

bool Firebase::Firestore::Timestamp::operator>(
  Timestamp lhs,
  Timestamp rhs
)

Compares two timestamps.

Details
Parameters
lhs
The left timestamp to compare.
rhs
The right timestamp to compare.
Returns
true if lhs is strictly later than rhs ; otherwise false.

operator>=

bool Firebase::Firestore::Timestamp::operator>=(
  Timestamp lhs,
  Timestamp rhs
)

Compares two timestamps.

Details
Parameters
lhs
The left timestamp to compare.
rhs
The right timestamp to compare.
Returns
true if lhs is later than or equal to rhs ; otherwise false.