Export of internal Abseil changes.
-- 7fa1107161a03dac53fb84c2b06d8092616c7b13 by Abseil Team <absl-team@google.com>: Harden the generic stacktrace implementation for use during early program execution PiperOrigin-RevId: 226375950 -- 079f9969329f5eb66f647dd3c44b17541b1bf217 by Matt Kulukundis <kfm@google.com>: Workaround platforms that have over-aggressive warnings on -Wexit-time-destructors PiperOrigin-RevId: 226362948 -- 1447943f509be681ca5495add0162c750ef237f1 by Matt Kulukundis <kfm@google.com>: Switch from 64 to size_t atomics so they work on embedded platforms that do not have 64 bit atomics. PiperOrigin-RevId: 226210704 -- d14d49837ae2bcde74051e0c79c18ee0f43866b9 by Tom Manshreck <shreck@google.com>: Develop initial documentation for API breaking changes process: PiperOrigin-RevId: 226210021 -- 7ea3d7fe0e86979dab83a5fc9cc3bf1d6cb3bd53 by Abseil Team <absl-team@google.com>: Import of CCTZ from GitHub. PiperOrigin-RevId: 226195522 -- 7de873e880d7f016a4fa1e08d626f0535cc470af by Abseil Team <absl-team@google.com>: Make Abseil LICENSE files newline terminated, with a single trailing blank line. Also remove line-ending whitespace. PiperOrigin-RevId: 226182949 -- 7d00643fadfad7f0d992c68bd9d2ed2e5bc960b0 by Matt Kulukundis <kfm@google.com>: Internal cleanup PiperOrigin-RevId: 226045282 -- c4a0a11c0ce2875271191e477f3d36eaaeca4613 by Matt Kulukundis <kfm@google.com>: Internal cleanup PiperOrigin-RevId: 226038273 -- 8ee4ebbb1ae5cda119e436e5ff7e3aa966608c10 by Matt Kulukundis <kfm@google.com>: Adds a global sampler which tracks a fraction of live tables for collecting telemetry data. PiperOrigin-RevId: 226032080 -- d576446f050518cd1b0ae447d682d8552f0e7e30 by Mark Barolak <mbar@google.com>: Replace an internal CaseEqual function with calls to the identical absl::EqualsIgnoreCase. This closes out a rather old TODO. PiperOrigin-RevId: 226024779 -- 6b23f1ee028a5ffa608c920424f1220a117a8f3d by Abseil Team <absl-team@google.com>: Add December 2018 LTS branch to list of LTS branches. PiperOrigin-RevId: 226011333 -- bb0833a43bdaef4c8c059b17bcd27ba9a085a114 by Mark Barolak <mbar@google.com>: Explicitly state that when the SimpleAtoi family of functions encounter an error, the value of their output parameter is unspecified. Also standardize the name of the output parameter to be `out`. PiperOrigin-RevId: 225997035 -- 46c1876b1a248eabda7545daa61a74a4cdfe9077 by Abseil Team <absl-team@google.com>: Remove deprecated CMake function absl_test, absl_library and absl_header_library PiperOrigin-RevId: 225950041 GitOrigin-RevId: 7fa1107161a03dac53fb84c2b06d8092616c7b13 Change-Id: I2ca9d3aada9292614527d1339a7557494139b806
This commit is contained in:
parent
3e2e9b5557
commit
968a34ffda
16 changed files with 1313 additions and 348 deletions
|
|
@ -149,15 +149,25 @@ char* FormatOffset(char* ep, int offset, const char* mode) {
|
|||
offset = -offset; // bounded by 24h so no overflow
|
||||
sign = '-';
|
||||
}
|
||||
char sep = mode[0];
|
||||
if (sep != '\0' && mode[1] == '*') {
|
||||
ep = Format02d(ep, offset % 60);
|
||||
const int seconds = offset % 60;
|
||||
const int minutes = (offset /= 60) % 60;
|
||||
const int hours = offset /= 60;
|
||||
const char sep = mode[0];
|
||||
const bool ext = (sep != '\0' && mode[1] == '*');
|
||||
const bool ccc = (ext && mode[2] == ':');
|
||||
if (ext && (!ccc || seconds != 0)) {
|
||||
ep = Format02d(ep, seconds);
|
||||
*--ep = sep;
|
||||
} else {
|
||||
// If we're not rendering seconds, sub-minute negative offsets
|
||||
// should get a positive sign (e.g., offset=-10s => "+00:00").
|
||||
if (hours == 0 && minutes == 0) sign = '+';
|
||||
}
|
||||
int minutes = offset / 60;
|
||||
ep = Format02d(ep, minutes % 60);
|
||||
if (sep != '\0') *--ep = sep;
|
||||
ep = Format02d(ep, minutes / 60);
|
||||
if (!ccc || minutes != 0 || seconds != 0) {
|
||||
ep = Format02d(ep, minutes);
|
||||
if (sep != '\0') *--ep = sep;
|
||||
}
|
||||
ep = Format02d(ep, hours);
|
||||
*--ep = sign;
|
||||
return ep;
|
||||
}
|
||||
|
|
@ -384,6 +394,44 @@ std::string format(const std::string& format, const time_point<seconds>& tp,
|
|||
continue;
|
||||
}
|
||||
|
||||
// More complex specifiers that we handle ourselves.
|
||||
if (*cur == ':' && cur + 1 != end) {
|
||||
if (*(cur + 1) == 'z') {
|
||||
// Formats %:z.
|
||||
if (cur - 1 != pending) {
|
||||
FormatTM(&result, std::string(pending, cur - 1), tm);
|
||||
}
|
||||
bp = FormatOffset(ep, al.offset, ":");
|
||||
result.append(bp, static_cast<std::size_t>(ep - bp));
|
||||
pending = cur += 2;
|
||||
continue;
|
||||
}
|
||||
if (*(cur + 1) == ':' && cur + 2 != end) {
|
||||
if (*(cur + 2) == 'z') {
|
||||
// Formats %::z.
|
||||
if (cur - 1 != pending) {
|
||||
FormatTM(&result, std::string(pending, cur - 1), tm);
|
||||
}
|
||||
bp = FormatOffset(ep, al.offset, ":*");
|
||||
result.append(bp, static_cast<std::size_t>(ep - bp));
|
||||
pending = cur += 3;
|
||||
continue;
|
||||
}
|
||||
if (*(cur + 2) == ':' && cur + 3 != end) {
|
||||
if (*(cur + 3) == 'z') {
|
||||
// Formats %:::z.
|
||||
if (cur - 1 != pending) {
|
||||
FormatTM(&result, std::string(pending, cur - 1), tm);
|
||||
}
|
||||
bp = FormatOffset(ep, al.offset, ":*:");
|
||||
result.append(bp, static_cast<std::size_t>(ep - bp));
|
||||
pending = cur += 4;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop if there is no E modifier.
|
||||
if (*cur != 'E' || ++cur == end) continue;
|
||||
|
||||
|
|
@ -668,17 +716,27 @@ bool parse(const std::string& format, const std::string& input,
|
|||
&percent_s);
|
||||
if (data != nullptr) saw_percent_s = true;
|
||||
continue;
|
||||
case ':':
|
||||
if (fmt[0] == 'z' ||
|
||||
(fmt[0] == ':' &&
|
||||
(fmt[1] == 'z' || (fmt[1] == ':' && fmt[2] == 'z')))) {
|
||||
data = ParseOffset(data, ":", &offset);
|
||||
if (data != nullptr) saw_offset = true;
|
||||
fmt += (fmt[0] == 'z') ? 1 : (fmt[1] == 'z') ? 2 : 3;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
data = (*data == '%' ? data + 1 : nullptr);
|
||||
continue;
|
||||
case 'E':
|
||||
if (*fmt == 'z' || (*fmt == '*' && *(fmt + 1) == 'z')) {
|
||||
if (fmt[0] == 'z' || (fmt[0] == '*' && fmt[1] == 'z')) {
|
||||
data = ParseOffset(data, ":", &offset);
|
||||
if (data != nullptr) saw_offset = true;
|
||||
fmt += (*fmt == 'z') ? 1 : 2;
|
||||
fmt += (fmt[0] == 'z') ? 1 : 2;
|
||||
continue;
|
||||
}
|
||||
if (*fmt == '*' && *(fmt + 1) == 'S') {
|
||||
if (fmt[0] == '*' && fmt[1] == 'S') {
|
||||
data = ParseInt(data, 2, 0, 60, &tm.tm_sec);
|
||||
if (data != nullptr && *data == '.') {
|
||||
data = ParseSubSeconds(data + 1, &subseconds);
|
||||
|
|
@ -686,14 +744,14 @@ bool parse(const std::string& format, const std::string& input,
|
|||
fmt += 2;
|
||||
continue;
|
||||
}
|
||||
if (*fmt == '*' && *(fmt + 1) == 'f') {
|
||||
if (fmt[0] == '*' && fmt[1] == 'f') {
|
||||
if (data != nullptr && std::isdigit(*data)) {
|
||||
data = ParseSubSeconds(data, &subseconds);
|
||||
}
|
||||
fmt += 2;
|
||||
continue;
|
||||
}
|
||||
if (*fmt == '4' && *(fmt + 1) == 'Y') {
|
||||
if (fmt[0] == '4' && fmt[1] == 'Y') {
|
||||
const char* bp = data;
|
||||
data = ParseInt(data, 4, year_t{-999}, year_t{9999}, &year);
|
||||
if (data != nullptr) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue