ztsdb
tz.hpp
1 // This file lifts out of localtime.c the main structures that we need in
2 // headers so that we can use them in our implementation of time zone
3 // handling. The main difference with the original code is the use of
4 // 'chrono::time_point' as the time type. Note the C++-style comments
5 // are non-original comments.
6 
7 // This appears in localtime.c and applies to the whole of this file
8 /*
9 ** This file is in the public domain, so clarified as of
10 ** 1996-06-05 by Arthur David Olson.
11 */
12 
13 /*
14 ** Leap second handling from Bradley White.
15 ** POSIX-style TZ environment variable handling from Guy Harris.
16 */
17 
18 
19 
20 #ifndef TZ_HPP
21 #define TZ_HPP
22 
23 
24 #include "tzfile.h"
25 
26 struct ttinfo { /* time type information */
27  int_fast32_t tt_utoff; /* UT offset in seconds */
28  bool tt_isdst; /* used to set tm_isdst */
29  int tt_desigidx; /* abbreviation list index */
30  bool tt_ttisstd; /* transition is std time */
31  bool tt_ttisut; /* transition is UT */
32 };
33 
34 struct lsinfo { /* leap second information */
35  time_t ls_trans; /* transition time */
36  int_fast64_t ls_corr; /* correction to apply */
37 };
38 
39 #define SMALLEST(a, b) (((a) < (b)) ? (a) : (b))
40 #define BIGGEST(a, b) (((a) > (b)) ? (a) : (b))
41 
42 #ifdef TZNAME_MAX
43 #define MY_TZNAME_MAX TZNAME_MAX
44 #endif /* defined TZNAME_MAX */
45 #ifndef TZNAME_MAX
46 #define MY_TZNAME_MAX 255
47 #endif /* !defined TZNAME_MAX */
48 
49 const char gmt[] = "GMT";
50 
51 struct state {
52  int leapcnt;
53  int timecnt;
54  int typecnt;
55  int charcnt;
56  bool goback;
57  bool goahead;
58  time_t ats[TZ_MAX_TIMES];
59  unsigned char types[TZ_MAX_TIMES];
60  struct ttinfo ttis[TZ_MAX_TYPES];
61  char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt),
62  (2 * (MY_TZNAME_MAX + 1)))];
63  struct lsinfo lsis[TZ_MAX_LEAPS];
64 
65  /* The time type to use for early times or if no transitions.
66  It is always zero for recent tzdb releases.
67  It might be nonzero for data from tzdb 2018e or earlier. */
68  int defaulttype;
69 };
70 
71 
72 #endif
lsinfo
Definition: tz.hpp:34
ttinfo
Definition: tz.hpp:26
state
Definition: tz.hpp:51