• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 Google Inc. All Rights Reserved.
2 //
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
6 //
7 //   https://www.apache.org/licenses/LICENSE-2.0
8 //
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.
14 
15 #ifndef ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_
16 #define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_
17 
18 #include <string>
19 
20 #include "absl/base/config.h"
21 #include "time_zone_if.h"
22 
23 namespace absl {
24 ABSL_NAMESPACE_BEGIN
25 namespace time_internal {
26 namespace cctz {
27 
28 // A time zone backed by gmtime_r(3), localtime_r(3), and mktime(3),
29 // and which therefore only supports UTC and the local time zone.
30 // TODO: Add support for fixed offsets from UTC.
31 class TimeZoneLibC : public TimeZoneIf {
32  public:
33   explicit TimeZoneLibC(const std::string& name);
34 
35   // TimeZoneIf implementations.
36   time_zone::absolute_lookup BreakTime(
37       const time_point<seconds>& tp) const override;
38   time_zone::civil_lookup MakeTime(const civil_second& cs) const override;
39   bool NextTransition(const time_point<seconds>& tp,
40                       time_zone::civil_transition* trans) const override;
41   bool PrevTransition(const time_point<seconds>& tp,
42                       time_zone::civil_transition* trans) const override;
43   std::string Version() const override;
44   std::string Description() const override;
45 
46  private:
47   const bool local_;  // localtime or UTC
48 };
49 
50 }  // namespace cctz
51 }  // namespace time_internal
52 ABSL_NAMESPACE_END
53 }  // namespace absl
54 
55 #endif  // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_
56