aboutsummaryrefslogtreecommitdiff
path: root/third_party/abseil-cpp/absl/time/civil_time.cc
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-14 03:07:06 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-14 03:07:06 +0000
commit39dbb21d63fcd4848f54cf7dfc7188f7216c36f4 (patch)
tree2ce94d7f0804ccb77d1fa9b2a1bca00eecdff1e2 /third_party/abseil-cpp/absl/time/civil_time.cc
parentf60eaea2240ba9e1c508e8e0c91d39ee9fc47be5 (diff)
parent6c9587948173932b64d97c288a947e43d2a2ac14 (diff)
downloadwebrtc-android13-qpr1-s4-release.tar.gz
Change-Id: I2cdc23e9d294e3701ac746469aea1ce793eb9ce4
Diffstat (limited to 'third_party/abseil-cpp/absl/time/civil_time.cc')
-rw-r--r--third_party/abseil-cpp/absl/time/civil_time.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/third_party/abseil-cpp/absl/time/civil_time.cc b/third_party/abseil-cpp/absl/time/civil_time.cc
index ada82cbc8d..6a231edb2d 100644
--- a/third_party/abseil-cpp/absl/time/civil_time.cc
+++ b/third_party/abseil-cpp/absl/time/civil_time.cc
@@ -38,16 +38,14 @@ std::string FormatYearAnd(string_view fmt, CivilSecond cs) {
const CivilSecond ncs(NormalizeYear(cs.year()), cs.month(), cs.day(),
cs.hour(), cs.minute(), cs.second());
const TimeZone utc = UTCTimeZone();
- // TODO(absl-team): Avoid conversion of fmt std::string.
- return StrCat(cs.year(),
- FormatTime(std::string(fmt), FromCivil(ncs, utc), utc));
+ return StrCat(cs.year(), FormatTime(fmt, FromCivil(ncs, utc), utc));
}
template <typename CivilT>
bool ParseYearAnd(string_view fmt, string_view s, CivilT* c) {
// Civil times support a larger year range than absl::Time, so we need to
// parse the year separately, normalize it, then use absl::ParseTime on the
- // normalized std::string.
+ // normalized string.
const std::string ss = std::string(s); // TODO(absl-team): Avoid conversion.
const char* const np = ss.c_str();
char* endp;
@@ -82,7 +80,7 @@ bool ParseAs(string_view s, CivilT2* c) {
template <typename CivilT>
bool ParseLenient(string_view s, CivilT* c) {
- // A fastpath for when the given std::string data parses exactly into the given
+ // A fastpath for when the given string data parses exactly into the given
// type T (e.g., s="YYYY-MM-DD" and CivilT=CivilDay).
if (ParseCivilTime(s, c)) return true;
// Try parsing as each of the 6 types, trying the most common types first
@@ -98,26 +96,26 @@ bool ParseLenient(string_view s, CivilT* c) {
} // namespace
std::string FormatCivilTime(CivilSecond c) {
- return FormatYearAnd("-%m-%dT%H:%M:%S", c);
+ return FormatYearAnd("-%m-%d%ET%H:%M:%S", c);
}
std::string FormatCivilTime(CivilMinute c) {
- return FormatYearAnd("-%m-%dT%H:%M", c);
+ return FormatYearAnd("-%m-%d%ET%H:%M", c);
}
std::string FormatCivilTime(CivilHour c) {
- return FormatYearAnd("-%m-%dT%H", c);
+ return FormatYearAnd("-%m-%d%ET%H", c);
}
std::string FormatCivilTime(CivilDay c) { return FormatYearAnd("-%m-%d", c); }
std::string FormatCivilTime(CivilMonth c) { return FormatYearAnd("-%m", c); }
std::string FormatCivilTime(CivilYear c) { return FormatYearAnd("", c); }
bool ParseCivilTime(string_view s, CivilSecond* c) {
- return ParseYearAnd("-%m-%dT%H:%M:%S", s, c);
+ return ParseYearAnd("-%m-%d%ET%H:%M:%S", s, c);
}
bool ParseCivilTime(string_view s, CivilMinute* c) {
- return ParseYearAnd("-%m-%dT%H:%M", s, c);
+ return ParseYearAnd("-%m-%d%ET%H:%M", s, c);
}
bool ParseCivilTime(string_view s, CivilHour* c) {
- return ParseYearAnd("-%m-%dT%H", s, c);
+ return ParseYearAnd("-%m-%d%ET%H", s, c);
}
bool ParseCivilTime(string_view s, CivilDay* c) {
return ParseYearAnd("-%m-%d", s, c);