public struct Timestamp : IEquatable<Timestamp>, IComparable, IComparable<Timestamp>Reference documentation and code samples for the Firestore API struct Timestamp.
A nanosecond-precision immutable timestamp. When this is stored as part of a document in Firestore, it is truncated to the microsecond, towards the start of time.
Namespace
Google.Cloud.FirestoreAssembly
Google.Cloud.Firestore.dll
Methods
CompareTo(Timestamp)
public int CompareTo(Timestamp other)| Parameter | |
|---|---|
| Name | Description |
other |
Timestamp |
| Returns | |
|---|---|
| Type | Description |
int |
|
CompareTo(object)
public int CompareTo(object obj)| Parameter | |
|---|---|
| Name | Description |
obj |
object |
| Returns | |
|---|---|
| Type | Description |
int |
|
FromDateTime(DateTime)
public static Timestamp FromDateTime(DateTime dateTime)| Parameter | |
|---|---|
| Name | Description |
dateTime |
DateTimeThe value to convert; its kind must be Utc. |
| Returns | |
|---|---|
| Type | Description |
Timestamp |
A Timestamp representation of |
FromDateTimeOffset(DateTimeOffset)
public static Timestamp FromDateTimeOffset(DateTimeOffset dateTimeOffset)Converts the given DateTimeOffset to a Timestamp
| Parameter | |
|---|---|
| Name | Description |
dateTimeOffset |
DateTimeOffsetThe date and time (with UTC offset) to convert to a timestamp. |
| Returns | |
|---|---|
| Type | Description |
Timestamp |
The converted 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
roundtrip operation to retrieve the original DateTimeOffset.
FromProto(Timestamp)
public static Timestamp FromProto(Timestamp proto)Creates an instance from a Protobuf Timestamp representation. Later modifications to the Protobuf representation will not affect the returned oject.
| Parameter | |
|---|---|
| Name | Description |
proto |
TimestampA Protobuf timestamp representation. Must not be null. |
| Returns | |
|---|---|
| Type | Description |
Timestamp |
An immutable timestamp. |
GetCurrentTimestamp()
public static 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.
| Returns | |
|---|---|
| Type | Description |
Timestamp |
The current timestamp according to the system clock. |
GetHashCode()
public override int GetHashCode()| Returns | |
|---|---|
| Type | Description |
int |
|
ToDateTime()
public DateTime ToDateTime()Converts this timestamp to a DateTime with a kind of 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.
| Returns | |
|---|---|
| Type | Description |
DateTime |
A DateTime representation of this timestamp. |
ToDateTimeOffset()
public DateTimeOffset ToDateTimeOffset()Converts this timestamp into a DateTimeOffset.
| Returns | |
|---|---|
| Type | Description |
DateTimeOffset |
This timestamp as a |
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.
ToProto()
public Timestamp ToProto()Creates a Protobuf Timestamp representation of this timestamp. Modifications to the returned message will not be reflected in this object.
| Returns | |
|---|---|
| Type | Description |
Timestamp |
A Protobuf timestamp representation. |
ToString()
public override string ToString()| Returns | |
|---|---|
| Type | Description |
string |
|
Operators
operator ==(Timestamp, Timestamp)
public static bool operator ==(Timestamp lhs, Timestamp rhs)Operator overload to compare two Blob values for equality.
| Parameters | |
|---|---|
| Name | Description |
lhs |
TimestampLeft value to compare |
rhs |
TimestampRight value to compare |
| Returns | |
|---|---|
| Type | Description |
bool |
true if |
operator >(Timestamp, Timestamp)
public static bool operator >(Timestamp lhs, Timestamp rhs)Compares two timestamps.
| Parameters | |
|---|---|
| Name | Description |
lhs |
TimestampThe left timestamp to compare. |
rhs |
TimestampThe right timestamp to compare. |
| Returns | |
|---|---|
| Type | Description |
bool |
true is |
operator >=(Timestamp, Timestamp)
public static bool operator >=(Timestamp lhs, Timestamp rhs)Compares two timestamps.
| Parameters | |
|---|---|
| Name | Description |
lhs |
TimestampThe left timestamp to compare. |
rhs |
TimestampThe right timestamp to compare. |
| Returns | |
|---|---|
| Type | Description |
bool |
true is |
operator !=(Timestamp, Timestamp)
public static bool operator !=(Timestamp lhs, Timestamp rhs)Operator overload to compare two Blob values for inequality.
| Parameters | |
|---|---|
| Name | Description |
lhs |
TimestampLeft value to compare |
rhs |
TimestampRight value to compare |
| Returns | |
|---|---|
| Type | Description |
bool |
false if |
operator <(Timestamp, Timestamp)
public static bool operator <(Timestamp lhs, Timestamp rhs)Compares two timestamps.
| Parameters | |
|---|---|
| Name | Description |
lhs |
TimestampThe left timestamp to compare. |
rhs |
TimestampThe right timestamp to compare. |
| Returns | |
|---|---|
| Type | Description |
bool |
true is |
operator <=(Timestamp, Timestamp)
public static bool operator <=(Timestamp lhs, Timestamp rhs)Compares two timestamps.
| Parameters | |
|---|---|
| Name | Description |
lhs |
TimestampThe left timestamp to compare. |
rhs |
TimestampThe right timestamp to compare. |
| Returns | |
|---|---|
| Type | Description |
bool |
true is |