Firebase. Firestore. Timestamp
A nanosecond-precision immutable timestamp.
Summary
When this is stored as part of a document inFirestore, it is truncated to the microsecond, towards the start of time.
ATimestamp 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() | DateTimeConverts this timestamp to a DateTime with a kind of DateTimeKind.Utc. |
ToDateTimeOffset() | DateTimeOffsetConverts this timestamp into a DateTimeOffset. |
ToString() | override string |
Public static functions | |
|---|---|
FromDateTime(DateTime dateTime) | Converts a DateTime to aTimestamp. |
FromDateTimeOffset(DateTimeOffset dateTimeOffset) | Converts the given DateTimeOffset to aTimestamp |
GetCurrentTimestamp() | Returns the current timestamp according to the system clock. |
operator!=(Timestamp lhs,Timestamp rhs) | boolOperator overload to compare twoTimestamp values for inequality. |
operator<(Timestamp lhs,Timestamp rhs) | boolCompares two timestamps. |
operator<=(Timestamp lhs,Timestamp rhs) | boolCompares two timestamps. |
operator==(Timestamp lhs,Timestamp rhs) | boolOperator overload to compare twoTimestamp values for equality. |
operator>(Timestamp lhs,Timestamp rhs) | boolCompares two timestamps. |
operator>=(Timestamp lhs,Timestamp rhs) | boolCompares two timestamps. |
Public functions
CompareTo
intFirebase::Firestore::Timestamp::CompareTo(Timestampother)
CompareTo
intFirebase::Firestore::Timestamp::CompareTo(objectobj)
Equals
overrideboolFirebase::Firestore::Timestamp::Equals(objectobj)
Equals
boolFirebase::Firestore::Timestamp::Equals(Timestampother)
GetHashCode
overrideintFirebase::Firestore::Timestamp::GetHashCode()
ToDateTime
DateTimeFirebase::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
DateTimeOffsetFirebase::Firestore::Timestamp::ToDateTimeOffset()
Converts this timestamp into a DateTimeOffset.
The resultingDateTimeOffset will always have anOffset 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
overridestringFirebase::Firestore::Timestamp::ToString()
Public static functions
FromDateTime
TimestampFirebase::Firestore::Timestamp::FromDateTime(DateTimedateTime)
FromDateTimeOffset
TimestampFirebase::Firestore::Timestamp::FromDateTimeOffset(DateTimeOffsetdateTimeOffset)
Converts the given DateTimeOffset to aTimestamp
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 originalDateTimeOffset.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | The converted timestamp. |
GetCurrentTimestamp
TimestampFirebase::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!=
boolFirebase::Firestore::Timestamp::operator!=(Timestamplhs,Timestamprhs)
Operator overload to compare twoTimestamp values for inequality.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | false iflhs is equal torhs ; otherwisetrue. |
operator<
boolFirebase::Firestore::Timestamp::operator<(Timestamplhs,Timestamprhs)
Compares two timestamps.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | true iflhs is strictly earlier thanrhs ; otherwisefalse. |
operator<=
boolFirebase::Firestore::Timestamp::operator<=(Timestamplhs,Timestamprhs)
Compares two timestamps.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | true iflhs is earlier than or equal torhs ; otherwisefalse. |
operator==
boolFirebase::Firestore::Timestamp::operator==(Timestamplhs,Timestamprhs)
Operator overload to compare twoTimestamp values for equality.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | true iflhs is equal torhs ; otherwisefalse. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-06-17 UTC.