Main Page
Namespaces
Classes
Files
File List
File Members
abseil_cpp
absl
time
internal
cctz
src
time_zone_posix.h
Go to the documentation of this file.
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
// Parsing of a POSIX zone spec as described in the TZ part of section 8.3 in
16
// http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html.
17
//
18
// The current POSIX spec for America/Los_Angeles is "PST8PDT,M3.2.0,M11.1.0",
19
// which would be broken down as ...
20
//
21
// PosixTimeZone {
22
// std_abbr = "PST"
23
// std_offset = -28800
24
// dst_abbr = "PDT"
25
// dst_offset = -25200
26
// dst_start = PosixTransition {
27
// date {
28
// m {
29
// month = 3
30
// week = 2
31
// weekday = 0
32
// }
33
// }
34
// time {
35
// offset = 7200
36
// }
37
// }
38
// dst_end = PosixTransition {
39
// date {
40
// m {
41
// month = 11
42
// week = 1
43
// weekday = 0
44
// }
45
// }
46
// time {
47
// offset = 7200
48
// }
49
// }
50
// }
51
52
#ifndef ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_POSIX_H_
53
#define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_POSIX_H_
54
55
#include <cstdint>
56
#include <string>
57
58
namespace
absl
{
59
namespace
time_internal {
60
namespace
cctz
{
61
62
// The date/time of the transition. The date is specified as either:
63
// (J) the Nth day of the year (1 <= N <= 365), excluding leap days, or
64
// (N) the Nth day of the year (0 <= N <= 365), including leap days, or
65
// (M) the Nth weekday of a month (e.g., the 2nd Sunday in March).
66
// The time, specified as a day offset, identifies the particular moment
67
// of the transition, and may be negative or >= 24h, and in which case
68
// it would take us to another day, and perhaps week, or even month.
69
struct
PosixTransition
{
70
enum
DateFormat
{
J
,
N
,
M
};
71
72
struct
Date
{
73
struct
NonLeapDay
{
74
std::int_fast16_t
day
;
// day of non-leap year [1:365]
75
};
76
struct
Day
{
77
std::int_fast16_t
day
;
// day of year [0:365]
78
};
79
struct
MonthWeekWeekday
{
80
std::int_fast8_t
month
;
// month of year [1:12]
81
std::int_fast8_t
week
;
// week of month [1:5] (5==last)
82
std::int_fast8_t
weekday
;
// 0==Sun, ..., 6=Sat
83
};
84
85
DateFormat
fmt
;
86
87
union
{
88
NonLeapDay
j
;
89
Day
n
;
90
MonthWeekWeekday
m
;
91
};
92
};
93
94
struct
Time
{
95
std::int_fast32_t
offset
;
// seconds before/after 00:00:00
96
};
97
98
Date
date
;
99
Time
time
;
100
};
101
102
// The entirety of a POSIX-string specified time-zone rule. The standard
103
// abbreviation and offset are always given. If the time zone includes
104
// daylight saving, then the daylight abbrevation is non-empty and the
105
// remaining fields are also valid. Note that the start/end transitions
106
// are not ordered---in the southern hemisphere the transition to end
107
// daylight time occurs first in any particular year.
108
struct
PosixTimeZone
{
109
std::string
std_abbr
;
110
std::int_fast32_t
std_offset
;
111
112
std::string
dst_abbr
;
113
std::int_fast32_t
dst_offset
;
114
PosixTransition
dst_start
;
115
PosixTransition
dst_end
;
116
};
117
118
// Breaks down a POSIX time-zone specification into its constituent pieces,
119
// filling in any missing values (DST offset, or start/end transition times)
120
// with the standard-defined defaults. Returns false if the specification
121
// could not be parsed (although some fields of *res may have been altered).
122
bool
ParsePosixSpec
(
const
std::string& spec,
PosixTimeZone
* res);
123
124
}
// namespace cctz
125
}
// namespace time_internal
126
}
// namespace absl
127
128
#endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_POSIX_H_
absl::time_internal::cctz::PosixTimeZone::std_abbr
std::string std_abbr
Definition:
time_zone_posix.h:109
absl::time_internal::cctz::PosixTransition::date
Date date
Definition:
time_zone_posix.h:98
absl::time_internal::cctz::ParsePosixSpec
bool ParsePosixSpec(const std::string &spec, PosixTimeZone *res)
Definition:
time_zone_posix.cc:133
absl::time_internal::cctz::PosixTransition::Date::MonthWeekWeekday::week
std::int_fast8_t week
Definition:
time_zone_posix.h:81
absl::time_internal::cctz
Definition:
internal/cctz/include/cctz/civil_time.h:22
absl::time_internal::cctz::PosixTransition
Definition:
time_zone_posix.h:69
absl::time_internal::cctz::PosixTransition::M
Definition:
time_zone_posix.h:70
absl::time_internal::cctz::PosixTransition::Date::MonthWeekWeekday::month
std::int_fast8_t month
Definition:
time_zone_posix.h:80
absl::time_internal::cctz::PosixTimeZone::dst_start
PosixTransition dst_start
Definition:
time_zone_posix.h:114
absl::time_internal::cctz::PosixTransition::Time
Definition:
time_zone_posix.h:94
absl::time_internal::cctz::PosixTransition::DateFormat
DateFormat
Definition:
time_zone_posix.h:70
absl
Definition:
algorithm.h:29
absl::time_internal::cctz::PosixTransition::Date::MonthWeekWeekday::weekday
std::int_fast8_t weekday
Definition:
time_zone_posix.h:82
absl::time_internal::cctz::PosixTransition::Date::Day
Definition:
time_zone_posix.h:76
absl::time_internal::cctz::PosixTransition::Date
Definition:
time_zone_posix.h:72
absl::time_internal::cctz::PosixTransition::N
Definition:
time_zone_posix.h:70
absl::time_internal::cctz::PosixTransition::J
Definition:
time_zone_posix.h:70
absl::time_internal::cctz::PosixTimeZone
Definition:
time_zone_posix.h:108
absl::time_internal::cctz::PosixTransition::Date::m
MonthWeekWeekday m
Definition:
time_zone_posix.h:90
absl::time_internal::cctz::PosixTimeZone::std_offset
std::int_fast32_t std_offset
Definition:
time_zone_posix.h:110
absl::time_internal::cctz::PosixTimeZone::dst_abbr
std::string dst_abbr
Definition:
time_zone_posix.h:112
absl::time_internal::cctz::PosixTransition::Date::NonLeapDay::day
std::int_fast16_t day
Definition:
time_zone_posix.h:74
absl::time_internal::cctz::PosixTransition::Date::MonthWeekWeekday
Definition:
time_zone_posix.h:79
absl::time_internal::cctz::PosixTransition::Date::NonLeapDay
Definition:
time_zone_posix.h:73
absl::time_internal::cctz::PosixTransition::Date::n
Day n
Definition:
time_zone_posix.h:89
absl::time_internal::cctz::PosixTimeZone::dst_offset
std::int_fast32_t dst_offset
Definition:
time_zone_posix.h:113
absl::time_internal::cctz::PosixTransition::Date::Day::day
std::int_fast16_t day
Definition:
time_zone_posix.h:77
absl::time_internal::cctz::PosixTransition::Date::j
NonLeapDay j
Definition:
time_zone_posix.h:88
absl::time_internal::cctz::PosixTransition::Date::fmt
DateFormat fmt
Definition:
time_zone_posix.h:85
absl::time_internal::cctz::PosixTransition::time
Time time
Definition:
time_zone_posix.h:99
absl::time_internal::cctz::PosixTimeZone::dst_end
PosixTransition dst_end
Definition:
time_zone_posix.h:115
absl::time_internal::cctz::PosixTransition::Time::offset
std::int_fast32_t offset
Definition:
time_zone_posix.h:95
abseil_cpp
Author(s):
autogenerated on Tue Jun 18 2019 19:44:37