Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / lib / libast / tm / tmdata.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: tmdata.c /main/3 1995/11/01 18:53:32 rswiston $ */
24 /***************************************************************
25 *                                                              *
26 *                      AT&T - PROPRIETARY                      *
27 *                                                              *
28 *         THIS IS PROPRIETARY SOURCE CODE LICENSED BY          *
29 *                          AT&T CORP.                          *
30 *                                                              *
31 *                Copyright (c) 1995 AT&T Corp.                 *
32 *                     All Rights Reserved                      *
33 *                                                              *
34 *           This software is licensed by AT&T Corp.            *
35 *       under the terms and conditions of the license in       *
36 *       http://www.research.att.com/orgs/ssr/book/reuse        *
37 *                                                              *
38 *               This software was created by the               *
39 *           Software Engineering Research Department           *
40 *                    AT&T Bell Laboratories                    *
41 *                                                              *
42 *               For further information contact                *
43 *                     gsf@research.att.com                     *
44 *                                                              *
45 ***************************************************************/
46
47 /* : : generated by proto : : */
48
49 #if !defined(__PROTO__)
50 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
51 #if defined(__cplusplus)
52 #define __MANGLE__      "C"
53 #else
54 #define __MANGLE__
55 #endif
56 #define __STDARG__
57 #define __PROTO__(x)    x
58 #define __OTORP__(x)
59 #define __PARAM__(n,o)  n
60 #if !defined(__STDC__) && !defined(__cplusplus)
61 #if !defined(c_plusplus)
62 #define const
63 #endif
64 #define signed
65 #define void            int
66 #define volatile
67 #define __V_            char
68 #else
69 #define __V_            void
70 #endif
71 #else
72 #define __PROTO__(x)    ()
73 #define __OTORP__(x)    x
74 #define __PARAM__(n,o)  o
75 #define __MANGLE__
76 #define __V_            char
77 #define const
78 #define signed
79 #define void            int
80 #define volatile
81 #endif
82 #if defined(__cplusplus) || defined(c_plusplus)
83 #define __VARARG__      ...
84 #else
85 #define __VARARG__
86 #endif
87 #if defined(__STDARG__)
88 #define __VA_START__(p,a)       va_start(p,a)
89 #else
90 #define __VA_START__(p,a)       va_start(p)
91 #endif
92 #endif
93 #include <ast.h>
94 #include <tm.h>
95
96 /*
97  * default format strings -- must agree with TM_* indices
98  */
99
100 static char*            format[] =
101 {
102         "Jan",          "Feb",          "Mar",          "Apr",
103         "May",          "Jun",          "Jul",          "Aug",
104         "Sep",          "Oct",          "Nov",          "Dec",
105
106         "January",      "February",     "March",        "April",
107         "May",          "June",         "July",         "August",
108         "September",    "October",      "November",     "December",
109
110         "Sun",          "Mon",          "Tue",          "Wed",
111         "Thu",          "Fri",          "Sat",
112
113         "Sunday",       "Monday",       "Tuesday",      "Wednesday",
114         "Thursday",     "Friday",       "Saturday",
115
116         "%H:%M:%S",     "%m/%d/%y",     "%a %b %e %T %Z %Y",
117
118         "AM",           "PM",
119
120         "GMT",          "UTC",          "UCT",          "CUT",
121
122         "DST",          "",             "",             "",
123
124         "s",            "es",           "",             "",
125
126         "second",       "minute",       "hour",         "day",
127         "week",         "month",        "year",
128
129         "midnight",     "morning",      "noon",         "evening",
130
131         "yesterday",    "today",        "tomorrow",
132
133         "last",         "ago",          "past",
134         "this",         "now",          "current",
135         "in",           "next",         "hence",
136         "exactly",      "",             "",
137
138         "at",           "on",           "",             "",
139 };
140
141 /*
142  * format[] lex type classes
143  */
144
145 static char             lex[] =
146 {
147         TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,
148         TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,
149         TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,
150
151         TM_MONTH,       TM_MONTH,       TM_MONTH,       TM_MONTH,
152         TM_MONTH,       TM_MONTH,       TM_MONTH,       TM_MONTH,
153         TM_MONTH,       TM_MONTH,       TM_MONTH,       TM_MONTH,
154
155         TM_DAY_3,       TM_DAY_3,       TM_DAY_3,       TM_DAY_3,
156         TM_DAY_3,       TM_DAY_3,       TM_DAY_3,
157
158         TM_DAY,         TM_DAY,         TM_DAY,         TM_DAY,
159         TM_DAY,         TM_DAY,         TM_DAY,
160
161         TM_TIME,        TM_DATE,        TM_DEFAULT,
162
163         TM_MERIDIAN,    TM_MERIDIAN,
164
165         TM_UT,          TM_UT,          TM_UT,          TM_UT,
166         TM_DT,          TM_DT,          TM_DT,          TM_DT,
167
168         TM_SUFFIXES,    TM_SUFFIXES,    TM_SUFFIXES,    TM_SUFFIXES,
169
170         TM_PARTS,       TM_PARTS,       TM_PARTS,       TM_PARTS,
171         TM_PARTS,       TM_PARTS,       TM_PARTS,
172
173         TM_HOURS,       TM_HOURS,       TM_HOURS,       TM_HOURS,
174
175         TM_DAYS,        TM_DAYS,        TM_DAYS,
176
177         TM_LAST,        TM_LAST,        TM_LAST,
178         TM_THIS,        TM_THIS,        TM_THIS,
179         TM_NEXT,        TM_NEXT,        TM_NEXT,
180         TM_EXACT,       TM_EXACT,       TM_EXACT,
181
182         TM_NOISE,       TM_NOISE,       TM_NOISE,       TM_NOISE,
183 };
184
185 /*
186  * output format digits
187  */
188
189 static char     digit[] = "0123456789";
190
191 /*
192  * number of days in month i
193  */
194
195 static short    days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
196
197 /*
198  * sum of days in months before month i
199  */
200
201 static short    sum[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
202
203 /*
204  * leap second time_t and accumulated adjustments
205  * (reverse order -- biased for recent dates)
206  *
207  * tl.time is the seconds since the epoch for the leap event
208  *
209  *      adding:         the first additional second
210  *      subtracting:    the first dissappearing second
211  */
212
213 static Tm_leap_t        leap[] =
214 {
215           741484817,   18,              /* Jun 30 23:59:60 GMT 1993 */
216           709948816,   17,              /* Jun 30 23:59:60 GMT 1992 */
217           662688015,   16,              /* Dec 31 23:59:60 GMT 1990 */
218           631152014,   15,              /* Dec 31 23:59:60 GMT 1989 */
219           567993613,   14,              /* Dec 31 23:59:60 GMT 1987 */
220           489024012,   13,              /* Jun 30 23:59:60 GMT 1985 */
221           425865611,   12,              /* Jun 30 23:59:60 GMT 1983 */
222           394329610,   11,              /* Jun 30 23:59:60 GMT 1982 */
223           362793609,   10,              /* Jun 30 23:59:60 GMT 1981 */
224           315532808,    9,              /* Dec 31 23:59:60 GMT 1979 */
225           283996807,    8,              /* Dec 31 23:59:60 GMT 1978 */
226           252460806,    7,              /* Dec 31 23:59:60 GMT 1977 */
227           220924805,    6,              /* Dec 31 23:59:60 GMT 1976 */
228           189302404,    5,              /* Dec 31 23:59:60 GMT 1975 */
229           157766403,    4,              /* Dec 31 23:59:60 GMT 1974 */
230           126230402,    3,              /* Dec 31 23:59:60 GMT 1973 */
231            94694401,    2,              /* Dec 31 23:59:60 GMT 1972 */
232            78796800,    1,              /* Jun 30 23:59:60 GMT 1972 */
233                   0,    0,              /* can reference (tl+1)     */
234                   0,    0
235 };
236
237 /*
238  * time zones
239  *
240  * the UTC entries must be first
241  *
242  * zones with the same type are contiguous with all but the
243  * first entry for the type having a null type
244  *
245  * tz.standard is the sentinel
246  */
247
248 static Tm_zone_t        zone[] =
249 {
250  0,     "GMT",  0,       ( 0 * 60),          0, /* UTC                  */
251  0,     "UCT",  0,       ( 0 * 60),          0, /* UTC                  */
252  0,     "UTC",  0,       ( 0 * 60),          0, /* UTC                  */
253  0,     "CUT",  0,       ( 0 * 60),          0, /* UTC                  */
254  "USA", "HST",  0,       (10 * 60),          0, /* Hawaii               */
255  0,     "YST",  "YDT",   ( 9 * 60),     TM_DST, /* Yukon                */
256  0,     "PST",  "PDT",   ( 8 * 60),     TM_DST, /* Pacific              */
257  0,     "PST",  "PPET",  ( 8 * 60),     TM_DST, /* Pacific pres elect   */
258  0,     "MST",  "MDT",   ( 7 * 60),     TM_DST, /* Mountain             */
259  0,     "CST",  "CDT",   ( 6 * 60),     TM_DST, /* Central              */
260  0,     "EST",  "EDT",   ( 5 * 60),     TM_DST, /* Eastern              */
261  "CAN", "AST",  "ADT",   ( 4 * 60),     TM_DST, /* Atlantic             */
262  0,     "NST",  0,       ( 3 * 60 + 30),     0, /* Newfoundland         */
263  "GBR", "",     "BST",   ( 0 * 60),     TM_DST, /* British Summer       */
264  "EUR", "WET",  0,       ( 0 * 60),     TM_DST, /* Western Eurpoean     */
265  0,     "CET",  0,      -( 1 * 60),     TM_DST, /* Central European     */
266  0,     "MET",  0,      -( 1 * 60),     TM_DST, /* Middle European      */
267  0,     "EET",  0,      -( 2 * 60),     TM_DST, /* Eastern Eurpoean     */
268  "ISR", "IST",  "IDT",  -( 3 * 60),     TM_DST, /* Israel               */
269  "IND", "IST",  0,      -( 5 * 60 + 30 ),    0, /* India                */
270  "CHN", "HKT",  0,      -( 8 * 60),          0, /* Hong Kong            */
271  "KOR", "KST",  "KDT",  -( 8 * 60),     TM_DST, /* Korea                */
272  "SNG", "SST",  0,      -( 8 * 60),          0, /* Singapore            */
273  "JPN", "JST",  0,      -( 9 * 60),          0, /* Japan                */
274  "AUS", "AWST", 0,      -( 8 * 60),          0, /* Australia Western    */
275  0,     "WST",  0,      -( 8 * 60),          0, /* Australia Western    */
276  0,     "ACST", 0,      -( 9 * 60 + 30),TM_DST, /* Australia Central    */
277  0,     "CST",  0,      -( 9 * 60 + 30),TM_DST, /* Australia Central    */
278  0,     "AEST", 0,      -(10 * 60),     TM_DST, /* Australia Eastern    */
279  0,     "EST",  0,      -(10 * 60),     TM_DST, /* Australia Eastern    */
280  "NZL", "NZST", "NZDT", -(12 * 60),     TM_DST, /* New Zealand          */
281  0,     0,      0,      0,                   0
282 };
283
284 #if _DLL_INDIRECT_DATA && !_DLL
285 static Tm_data_t tm_data_data =
286 #else
287 Tm_data_t tm_data =
288 #endif
289
290 { format, lex, digit, days, sum, leap, zone };
291
292 #if _DLL_INDIRECT_DATA && !_DLL
293 Tm_data_t tm_data = &tm_data_data;
294 #endif