summaryrefslogtreecommitdiff
path: root/absl/time/internal/cctz/src/time_zone_if.cc
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2023-09-07 13:16:09 -0400
committerGravatar Benjamin Barenblat <bbaren@google.com>2023-09-07 13:16:09 -0400
commit6fdbff8bbce2a1debdc060df381f39e3dcfb65af (patch)
tree71f1ef38477a65d5cce472fc042c90087c2bb351 /absl/time/internal/cctz/src/time_zone_if.cc
parent8d4a80fe37176b1170d7dce0772dea9584ec3e32 (diff)
parent29bf8085f3bf17b84d30e34b3d7ff8248fda404e (diff)
Merge new upstream LTS 20230802.0
Diffstat (limited to 'absl/time/internal/cctz/src/time_zone_if.cc')
-rw-r--r--absl/time/internal/cctz/src/time_zone_if.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/absl/time/internal/cctz/src/time_zone_if.cc b/absl/time/internal/cctz/src/time_zone_if.cc
index 0319b2f9..0e65cd9e 100644
--- a/absl/time/internal/cctz/src/time_zone_if.cc
+++ b/absl/time/internal/cctz/src/time_zone_if.cc
@@ -23,17 +23,19 @@ ABSL_NAMESPACE_BEGIN
namespace time_internal {
namespace cctz {
-std::unique_ptr<TimeZoneIf> TimeZoneIf::Load(const std::string& name) {
+std::unique_ptr<TimeZoneIf> TimeZoneIf::UTC() { return TimeZoneInfo::UTC(); }
+
+std::unique_ptr<TimeZoneIf> TimeZoneIf::Make(const std::string& name) {
// Support "libc:localtime" and "libc:*" to access the legacy
// localtime and UTC support respectively from the C library.
+ // NOTE: The "libc:*" zones are internal, test-only interfaces, and
+ // are subject to change/removal without notice. Do not use them.
if (name.compare(0, 5, "libc:") == 0) {
- return std::unique_ptr<TimeZoneIf>(new TimeZoneLibC(name.substr(5)));
+ return TimeZoneLibC::Make(name.substr(5));
}
- // Otherwise use the "zoneinfo" implementation by default.
- std::unique_ptr<TimeZoneInfo> tz(new TimeZoneInfo);
- if (!tz->Load(name)) tz.reset();
- return std::unique_ptr<TimeZoneIf>(tz.release());
+ // Otherwise use the "zoneinfo" implementation.
+ return TimeZoneInfo::Make(name);
}
// Defined out-of-line to avoid emitting a weak vtable in all TUs.