diff options
author | 2022-10-18 02:34:29 -0700 | |
---|---|---|
committer | 2022-10-18 02:35:17 -0700 | |
commit | 4bc7568c70822dae40eea3f27a3051a618021651 (patch) | |
tree | b7e9ef7372a4ff1daad77af2eb84e2b230dfc506 /absl/time/civil_time.h | |
parent | 94433ef0615616b1ccb8b2193bde777c10406ac0 (diff) |
Eliminate use of internal interfaces and make the test portable and expose it to OSS.
PiperOrigin-RevId: 481865072
Change-Id: I46364ec07df6aaff25911f8bd9e40dfee6c60626
Diffstat (limited to 'absl/time/civil_time.h')
-rw-r--r-- | absl/time/civil_time.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/absl/time/civil_time.h b/absl/time/civil_time.h index bb460044..5855bc73 100644 --- a/absl/time/civil_time.h +++ b/absl/time/civil_time.h @@ -70,8 +70,10 @@ #ifndef ABSL_TIME_CIVIL_TIME_H_ #define ABSL_TIME_CIVIL_TIME_H_ +#include <iosfwd> #include <string> +#include "absl/base/config.h" #include "absl/strings/string_view.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" @@ -530,6 +532,29 @@ std::ostream& operator<<(std::ostream& os, CivilHour h); std::ostream& operator<<(std::ostream& os, CivilMinute m); std::ostream& operator<<(std::ostream& os, CivilSecond s); +// AbslParseFlag() +// +// Parses the command-line flag string representation `s` into a civil-time +// value. Flags must be specified in a format that is valid for +// `absl::ParseLenientCivilTime()`. +bool AbslParseFlag(absl::string_view s, CivilSecond* c, std::string* error); +bool AbslParseFlag(absl::string_view s, CivilMinute* c, std::string* error); +bool AbslParseFlag(absl::string_view s, CivilHour* c, std::string* error); +bool AbslParseFlag(absl::string_view s, CivilDay* c, std::string* error); +bool AbslParseFlag(absl::string_view s, CivilMonth* c, std::string* error); +bool AbslParseFlag(absl::string_view s, CivilYear* c, std::string* error); + +// AbslUnparseFlag() +// +// Unparses a civil-time value into a command-line string representation using +// the format specified by `absl::ParseCivilTime()`. +std::string AbslUnparseFlag(CivilSecond c); +std::string AbslUnparseFlag(CivilMinute c); +std::string AbslUnparseFlag(CivilHour c); +std::string AbslUnparseFlag(CivilDay c); +std::string AbslUnparseFlag(CivilMonth c); +std::string AbslUnparseFlag(CivilYear c); + } // namespace time_internal ABSL_NAMESPACE_END |