import less(1)
[unleashed/tickless.git] / usr / src / lib / libast / common / tm / tmdata.c
blob7b5943a3de1adc8a754a92e818d4c6fffd1f9897
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
20 * *
21 ***********************************************************************/
22 #pragma prototyped
24 * Glenn Fowler
25 * AT&T Research
27 * time conversion support readonly data
30 #include <ast.h>
31 #include <tm.h>
34 * default format strings -- must agree with TM_* indices
37 static char* format[] =
39 "Jan", "Feb", "Mar", "Apr",
40 "May", "Jun", "Jul", "Aug",
41 "Sep", "Oct", "Nov", "Dec",
43 "January", "February", "March", "April",
44 "May", "June", "July", "August",
45 "September", "October", "November", "December",
47 "Sun", "Mon", "Tue", "Wed",
48 "Thu", "Fri", "Sat",
50 "Sunday", "Monday", "Tuesday", "Wednesday",
51 "Thursday", "Friday", "Saturday",
53 "%H:%M:%S", "%m/%d/%y", "%a %b %e %T %Z %Y",
55 "AM", "PM",
57 "GMT", "UTC", "UCT", "CUT",
59 "DST", "", "", "",
61 "s", "es", "", "",
63 "second", "minute", "hour", "day",
64 "week", "month", "year",
66 "midnight", "morning", "noon", "evening",
68 "yesterday", "today", "tomorrow",
70 "last", "ago", "past",
71 "this", "now", "current",
72 "in", "next", "hence",
73 "exactly", "", "",
75 "at", "on", "", "",
77 "st", "nd", "rd", "th", "th",
78 "th", "th", "th", "th", "th",
80 "", "", "", "", "",
81 "", "", "", "", "",
83 "%a %b %e %T %Y",
84 "%a %b %e %T %Z %Y",
85 "%a %b %e %T %z %Z %Y",
86 "%b %e %H:%M",
87 "%b %e %Y",
88 "%I:%M:%S %p",
90 "", "", "", "", "",
92 "first", "", "third", "fourth", "fifth",
93 "sixth", "seventh", "eighth", "ninth", "tenth",
95 "final", "ending", "nth",
97 "work", "working", "workday",
101 * format[] lex type classes
104 static unsigned char lex[] =
106 TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,
107 TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,
108 TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,
110 TM_MONTH, TM_MONTH, TM_MONTH, TM_MONTH,
111 TM_MONTH, TM_MONTH, TM_MONTH, TM_MONTH,
112 TM_MONTH, TM_MONTH, TM_MONTH, TM_MONTH,
114 TM_DAY_ABBREV, TM_DAY_ABBREV, TM_DAY_ABBREV, TM_DAY_ABBREV,
115 TM_DAY_ABBREV, TM_DAY_ABBREV, TM_DAY_ABBREV,
117 TM_DAY, TM_DAY, TM_DAY, TM_DAY,
118 TM_DAY, TM_DAY, TM_DAY,
120 0, 0, 0,
122 TM_MERIDIAN, TM_MERIDIAN,
124 TM_UT, TM_UT, TM_UT, TM_UT,
125 TM_DT, TM_DT, TM_DT, TM_DT,
127 TM_SUFFIXES, TM_SUFFIXES, TM_SUFFIXES, TM_SUFFIXES,
129 TM_PARTS, TM_PARTS, TM_PARTS, TM_PARTS,
130 TM_PARTS, TM_PARTS, TM_PARTS,
132 TM_HOURS, TM_HOURS, TM_HOURS, TM_HOURS,
134 TM_DAYS, TM_DAYS, TM_DAYS,
136 TM_LAST, TM_LAST, TM_LAST,
137 TM_THIS, TM_THIS, TM_THIS,
138 TM_NEXT, TM_NEXT, TM_NEXT,
139 TM_EXACT, TM_EXACT, TM_EXACT,
141 TM_NOISE, TM_NOISE, TM_NOISE, TM_NOISE,
143 TM_ORDINAL, TM_ORDINAL, TM_ORDINAL, TM_ORDINAL, TM_ORDINAL,
144 TM_ORDINAL, TM_ORDINAL, TM_ORDINAL, TM_ORDINAL, TM_ORDINAL,
146 0, 0, 0, 0, 0,
147 0, 0, 0, 0, 0,
149 0, 0, 0,
150 0, 0, 0,
152 0, 0, 0, 0, 0,
154 TM_ORDINALS, TM_ORDINALS, TM_ORDINALS, TM_ORDINALS, TM_ORDINALS,
155 TM_ORDINALS, TM_ORDINALS, TM_ORDINALS, TM_ORDINALS, TM_ORDINALS,
157 TM_FINAL, TM_FINAL, TM_FINAL,
159 TM_WORK, TM_WORK, TM_WORK,
163 * output format digits
166 static char digit[] = "0123456789";
169 * number of days in month i
172 static short days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
175 * sum of days in months before month i
178 static short sum[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
181 * leap second time_t and accumulated adjustments
182 * (reverse order -- biased for recent dates)
184 * tl.time is the seconds since the epoch for the leap event
186 * adding: the first additional second
187 * subtracting: the first dissappearing second
190 static Tm_leap_t leap[] =
192 1230768023, 24, /* 2008-12-31+23:59:60-0000 */
193 1136073622, 23, /* 2005-12-31+23:59:60-0000 */
194 915148821, 22, /* 1998-12-31+23:59:60-0000 */
195 867715220, 21, /* 1997-06-30+23:59:60-0000 */
196 820454419, 20, /* 1995-12-31+23:59:60-0000 */
197 773020818, 19, /* 1994-06-30+23:59:60-0000 */
198 741484817, 18, /* 1993-06-30+23:59:60-0000 */
199 709948816, 17, /* 1992-06-30+23:59:60-0000 */
200 662688015, 16, /* 1990-12-31+23:59:60-0000 */
201 631152014, 15, /* 1989-12-31+23:59:60-0000 */
202 567993613, 14, /* 1987-12-31+23:59:60-0000 */
203 489024012, 13, /* 1985-06-30+23:59:60-0000 */
204 425865611, 12, /* 1983-06-30+23:59:60-0000 */
205 394329610, 11, /* 1982-06-30+23:59:60-0000 */
206 362793609, 10, /* 1981-06-30+23:59:60-0000 */
207 315532808, 9, /* 1979-12-31+23:59:60-0000 */
208 283996807, 8, /* 1978-12-31+23:59:60-0000 */
209 252460806, 7, /* 1977-12-31+23:59:60-0000 */
210 220924805, 6, /* 1976-12-31+23:59:60-0000 */
211 189302404, 5, /* 1975-12-31+23:59:60-0000 */
212 157766403, 4, /* 1974-12-31+23:59:60-0000 */
213 126230402, 3, /* 1973-12-31+23:59:60-0000 */
214 94694401, 2, /* 1972-12-31+23:59:60-0000 */
215 78796800, 1, /* 1972-06-30+23:59:60-0000 */
216 0, 0, /* can reference (tl+1) */
217 0, 0
221 * time zones
223 * the UTC entries must be first
225 * zones with the same type are contiguous with all but the
226 * first entry for the type having a null type
228 * tz.standard is the sentinel
231 static Tm_zone_t zone[] =
233 0, "GMT", 0, ( 0 * 60), 0, /* UTC */
234 0, "UCT", 0, ( 0 * 60), 0, /* UTC */
235 0, "UTC", 0, ( 0 * 60), 0, /* UTC */
236 0, "CUT", 0, ( 0 * 60), 0, /* UTC */
237 0, "Z", 0, ( 0 * 60), 0, /* UTC */
238 "USA", "HST", 0, (10 * 60), 0, /* Hawaii */
239 0, "YST", "YDT", ( 9 * 60), TM_DST, /* Yukon */
240 0, "PST", "PDT", ( 8 * 60), TM_DST, /* Pacific */
241 0, "PST", "PPET", ( 8 * 60), TM_DST, /* Pacific pres elect */
242 0, "MST", "MDT", ( 7 * 60), TM_DST, /* Mountain */
243 0, "CST", "CDT", ( 6 * 60), TM_DST, /* Central */
244 0, "EST", "EDT", ( 5 * 60), TM_DST, /* Eastern */
245 "CAN", "AST", "ADT", ( 4 * 60), TM_DST, /* Atlantic */
246 0, "NST", 0, ( 3 * 60 + 30), 0, /* Newfoundland */
247 "GBR", "", "BST", ( 0 * 60), TM_DST, /* British Summer */
248 "EUR", "WET", "WEST", ( 0 * 60), TM_DST, /* Western Eurpoean */
249 0, "CET", "CEST", -( 1 * 60), TM_DST, /* Central European */
250 0, "MET", "MEST", -( 1 * 60), TM_DST, /* Middle European */
251 0, "EET", "EEST", -( 2 * 60), TM_DST, /* Eastern Eurpoean */
252 "ISR", "IST", "IDT", -( 3 * 60), TM_DST, /* Israel */
253 "IND", "IST", 0, -( 5 * 60 + 30 ), 0, /* India */
254 "CHN", "HKT", 0, -( 8 * 60), 0, /* Hong Kong */
255 "KOR", "KST", "KDT", -( 8 * 60), TM_DST, /* Korea */
256 "SNG", "SST", 0, -( 8 * 60), 0, /* Singapore */
257 "JPN", "JST", 0, -( 9 * 60), 0, /* Japan */
258 "AUS", "AWST", 0, -( 8 * 60), 0, /* Australia Western */
259 0, "WST", 0, -( 8 * 60), 0, /* Australia Western */
260 0, "ACST", 0, -( 9 * 60 + 30),TM_DST, /* Australia Central */
261 0, "CST", 0, -( 9 * 60 + 30),TM_DST, /* Australia Central */
262 0, "AEST", 0, -(10 * 60), TM_DST, /* Australia Eastern */
263 0, "EST", 0, -(10 * 60), TM_DST, /* Australia Eastern */
264 "NZL", "NZST", "NZDT", -(12 * 60), TM_DST, /* New Zealand */
265 0, 0, 0, 0, 0
269 * 2007-03-19 move tm_data from _tm_data_ to (*_tm_datap_)
270 * to allow future Tm_data_t growth
271 * by 2009 _tm_data_ can be static
274 #if _BLD_ast && defined(__EXPORT__)
275 #define extern extern __EXPORT__
276 #endif
278 extern Tm_data_t _tm_data_;
280 #undef extern
282 Tm_data_t _tm_data_ = { format, lex, digit, days, sum, leap, zone };
284 __EXTERN__(Tm_data_t, _tm_data_);
286 __EXTERN__(Tm_data_t*, _tm_datap_);
288 Tm_data_t* _tm_datap_ = &_tm_data_;