Timestamp(int64_t seconds, int32_t nanoseconds)
Timestamp(const Timestamp & other)
Timestamp
is trivially copyable. Timestamp(Timestamp && other)
Public functions | |
---|---|
ToString() const | std::string Returns a string representation of this Timestamp for logging/debugging purposes. |
ToTimePoint() const | std::chrono::time_point< Clock, Duration > Converts this Timestamp to a time_point . |
nanoseconds() const | int32_t The non-negative fractions of a second at nanosecond resolution. |
operator=(const Timestamp & other)=default | Copy assignment operator, Timestamp is trivially copyable. |
operator=(Timestamp && other)=default | Move assignment operator, equivalent to copying. |
seconds() const | int64_t The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. |
Public static functions | |
---|---|
FromTimePoint(std::chrono::time_point< std::chrono::system_clock > time_point) | Converts std::chrono::time_point to a Timestamp . |
FromTimeT(time_t seconds_since_unix_epoch) | Converts time_t to a Timestamp . |
Now() | Creates a new timestamp with the current date. |
Friend classes | |
---|---|
operator<< | friend std::ostream & Outputs the string representation of this Timestamp to the given stream. |
Timestamp()=default
Creates a new timestamp representing the epoch (with seconds and nanoseconds set to 0).
Timestamp(int64_tseconds,int32_tnanoseconds)
Creates a new timestamp.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
std::stringToString()const
Returns a string representation of this Timestamp
for logging/debugging purposes.
std::chrono::time_point<Clock,Duration>ToTimePoint()const
Converts this Timestamp
to a time_point
.
Important: if overflow would occur, the returned value will be the maximum or minimum value that Duration
can hold. Note in particular that long long
is insufficient to hold the full range of Timestamp
values with nanosecond precision (which is why Duration
defaults to microseconds
).
int32_tnanoseconds()const
The non-negative fractions of a second at nanosecond resolution.
Negative second values with fractions still have non-negative nanoseconds values that count forward in time.
Timestamp&operator=(constTimestamp&other)=default
Copy assignment operator, Timestamp
is trivially copyable.
Timestamp&operator=(Timestamp&&other)=default
Move assignment operator, equivalent to copying.
int64_tseconds()const
The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
TimestampFromTimePoint(std::chrono::time_point<std::chrono::system_clock>time_point)
Converts std::chrono::time_point
to a Timestamp
.
Details | |||
---|---|---|---|
Parameters |
|
TimestampFromTimeT(time_tseconds_since_unix_epoch)
Converts time_t
to a Timestamp
.
Details | |||
---|---|---|---|
Parameters |
| ||
Returns | a new timestamp with the given number of seconds and zero nanoseconds. |
TimestampNow()
Creates a new timestamp with the current date.
The precision is up to nanoseconds, depending on the system clock.
Details | |
---|---|
Returns | a new timestamp representing the current date. |
friendstd::ostream&operator<<(std::ostream&out,constTimestamp×tamp)
Outputs the string representation of this Timestamp
to the given stream.
See also:ToString()
for comments on the representation format.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-03-13 UTC.