1 // Copyright 2016 Google Inc. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // https://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_
16 #define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_
20 #include "time_zone_if.h"
23 namespace time_internal {
26 // A time zone backed by gmtime_r(3), localtime_r(3), and mktime(3),
27 // and which therefore only supports UTC and the local time zone.
28 // TODO: Add support for fixed offsets from UTC.
29 class TimeZoneLibC : public TimeZoneIf {
31 explicit TimeZoneLibC(const std::string& name);
33 // TimeZoneIf implementations.
34 time_zone::absolute_lookup BreakTime(
35 const time_point<seconds>& tp) const override;
36 time_zone::civil_lookup MakeTime(
37 const civil_second& cs) const override;
38 bool NextTransition(const time_point<seconds>& tp,
39 time_zone::civil_transition* trans) const override;
40 bool PrevTransition(const time_point<seconds>& tp,
41 time_zone::civil_transition* trans) const override;
42 std::string Version() const override;
43 std::string Description() const override;
46 const bool local_; // localtime or UTC
50 } // namespace time_internal
53 #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_