• 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_FIXED_H_
16 #define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_FIXED_H_
17 
18 #include <string>
19 
20 #include "absl/base/config.h"
21 #include "absl/time/internal/cctz/include/cctz/time_zone.h"
22 
23 namespace absl {
24 ABSL_NAMESPACE_BEGIN
25 namespace time_internal {
26 namespace cctz {
27 
28 // Helper functions for dealing with the names and abbreviations
29 // of time zones that are a fixed offset (seconds east) from UTC.
30 // FixedOffsetFromName() extracts the offset from a valid fixed-offset
31 // name, while FixedOffsetToName() and FixedOffsetToAbbr() generate
32 // the canonical zone name and abbreviation respectively for the given
33 // offset.
34 //
35 // A fixed-offset name looks like "Fixed/UTC<+-><hours>:<mins>:<secs>".
36 // Its abbreviation is of the form "UTC(<+->H?H(MM(SS)?)?)?" where the
37 // optional pieces are omitted when their values are zero.  (Note that
38 // the sign is the opposite of that used in a POSIX TZ specification.)
39 //
40 // Note: FixedOffsetFromName() fails on syntax errors or when the parsed
41 // offset exceeds 24 hours.  FixedOffsetToName() and FixedOffsetToAbbr()
42 // both produce "UTC" when the argument offset exceeds 24 hours.
43 bool FixedOffsetFromName(const std::string& name, seconds* offset);
44 std::string FixedOffsetToName(const seconds& offset);
45 std::string FixedOffsetToAbbr(const seconds& offset);
46 
47 }  // namespace cctz
48 }  // namespace time_internal
49 ABSL_NAMESPACE_END
50 }  // namespace absl
51 
52 #endif  // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_FIXED_H_
53