diff options
author | Abseil Team <absl-team@google.com> | 2023-03-13 17:04:58 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-03-13 17:05:47 -0700 |
commit | 52578edd8950227f1eb28821622c861804241de6 (patch) | |
tree | b5d91d0b9d53f10e45937cc6c5157c6ae22c683a /absl/time/time.h | |
parent | 7f47b00fca75bee477c8a2e3e8fc74a1cf7c743f (diff) |
Support AbslStringify in absl::Time and absl::Duration.
PiperOrigin-RevId: 516363556
Change-Id: Iae5e781d46dc8a8c4242ab460b57b65271b93159
Diffstat (limited to 'absl/time/time.h')
-rw-r--r-- | absl/time/time.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/absl/time/time.h b/absl/time/time.h index cc390082..01b55322 100644 --- a/absl/time/time.h +++ b/absl/time/time.h @@ -609,6 +609,12 @@ inline std::ostream& operator<<(std::ostream& os, Duration d) { return os << FormatDuration(d); } +// Support for StrFormat(), StrCat() etc. +template <typename Sink> +void AbslStringify(Sink& sink, Duration d) { + sink.Append(FormatDuration(d)); +} + // ParseDuration() // // Parses a duration string consisting of a possibly signed sequence of @@ -1386,6 +1392,12 @@ inline std::ostream& operator<<(std::ostream& os, Time t) { return os << FormatTime(t); } +// Support for StrFormat(), StrCat() etc. +template <typename Sink> +void AbslStringify(Sink& sink, Time t) { + sink.Append(FormatTime(t)); +} + // ParseTime() // // Parses an input string according to the provided format string and |