Support images on the tabs of pages that are added (not just the
[wine] / dlls / oleaut32 / parsedt.h
1 /*
2 PostgreSQL Data Base Management System (formerly known as Postgres, then
3 as Postgres95).
4
5 Copyright (c) 1994-7 Regents of the University of California
6
7 Permission to use, copy, modify, and distribute this software and its
8 documentation for any purpose, without fee, and without a written agreement
9 is hereby granted, provided that the above copyright notice and this
10 paragraph and the following two paragraphs appear in all copies.
11
12 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
13 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
14 LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
15 DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
16 POSSIBILITY OF SUCH DAMAGE.
17
18 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20 AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21 ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
22 PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 */
24 /*-------------------------------------------------------------------------
25  *
26  * dt.h--
27  *        Definitions for the date/time and other date/time support code.
28  *        The support code is shared with other date data types,
29  *         including abstime, reltime, date, and time.
30  *
31  *
32  * Copyright (c) 1994, Regents of the University of California
33  *
34  *-------------------------------------------------------------------------
35  */
36 #ifndef DT_H
37 #define DT_H
38
39 #include <time.h>
40 #include <math.h>
41
42 /* We have to include stdlib.h here because it defines many of these macros
43    on some platforms, and we only want our definitions used if stdlib.h doesn't
44    have its own.
45 */
46
47 #include <stdlib.h>
48
49 /* ----------------------------------------------------------------
50  *                              Section 1:      bool, true, false, TRUE, FALSE
51  * ----------------------------------------------------------------
52  */
53 /*
54  * bool --
55  *              Boolean value, either true or false.
56  *
57  */
58 #define false   ((char) 0)
59 #define true    ((char) 1)
60 #ifndef __cplusplus
61 #ifndef bool
62 typedef char bool;
63 #endif   /* ndef bool */
64 #endif   /* not C++ */
65 typedef bool *BoolPtr;
66
67 #ifndef TRUE
68 #define TRUE    1
69 #endif   /* TRUE */
70
71 #ifndef FALSE
72 #define FALSE   0
73 #endif   /* FALSE */
74
75
76
77 /* ----------------------------------------------------------------
78  *                              Section 3:      standard system types
79  * ----------------------------------------------------------------
80  */
81
82 /*
83  * intN --
84  *              Signed integer, EXACTLY N BITS IN SIZE,
85  *              used for numerical computations and the
86  *              frontend/backend protocol.
87  */
88 typedef signed char int8;               /* == 8 bits */
89 typedef signed short int16;             /* == 16 bits */
90 typedef signed int int32;               /* == 32 bits */
91
92 /*
93  * uintN --
94  *              Unsigned integer, EXACTLY N BITS IN SIZE,
95  *              used for numerical computations and the
96  *              frontend/backend protocol.
97  */
98 typedef unsigned char uint8;    /* == 8 bits */
99 typedef unsigned short uint16;  /* == 16 bits */
100 typedef unsigned int uint32;    /* == 32 bits */
101
102 /*
103  * floatN --
104  *              Floating point number, AT LEAST N BITS IN SIZE,
105  *              used for numerical computations.
106  *
107  *              Since sizeof(floatN) may be > sizeof(char *), always pass
108  *              floatN by reference.
109  */
110 typedef float float32data;
111 typedef double float64data;
112 typedef float *float32;
113 typedef double *float64;
114
115 /*
116  * boolN --
117  *              Boolean value, AT LEAST N BITS IN SIZE.
118  */
119 typedef uint8 bool8;                    /* >= 8 bits */
120 typedef uint16 bool16;                  /* >= 16 bits */
121 typedef uint32 bool32;                  /* >= 32 bits */
122
123
124 /* Date/Time Configuration
125  *
126  * Constants to pass info from runtime environment:
127  *      USE_POSTGRES_DATES specifies traditional postgres format for output.
128  *      USE_ISO_DATES specifies ISO-compliant format for output.
129  *      USE_SQL_DATES specified Oracle/Ingres-compliant format for output.
130  *      USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
131  *
132  * DateStyle specifies preference for date formatting for output.
133  * EuroDates if client prefers dates interpreted and written w/European conventions.
134  *
135  * HasCTZSet if client timezone is specified by client.
136  * CDayLight is the apparent daylight savings time status.
137  * CTimeZone is the timezone offset in seconds.
138  * CTZName is the timezone label.
139  */
140
141 #define USE_POSTGRES_DATES              0
142 #define USE_ISO_DATES                   1
143 #define USE_SQL_DATES                   2
144 #define USE_GERMAN_DATES                3
145
146 extern  int     DateStyle;
147 extern  bool    EuroDates;
148 extern  int     CTimeZone;
149
150 typedef double float8;
151
152 struct varlena
153 {
154         int             vl_len;
155         char            vl_dat[1];
156 };
157
158 typedef struct varlena text;
159
160
161
162 typedef int AbsoluteTime;
163 typedef int RelativeTime;
164
165 /*
166  * Note a leap year is one that is a multiple of 4
167  * but not of a 100.  Except if it is a multiple of
168  * 400 then it is a leap year.
169  */
170 #define isleap(y) (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
171
172 /*
173  * DateTime represents absolute time.
174  * TimeSpan represents delta time. Keep track of months (and years)
175  *      separately since the elapsed time spanned is unknown until instantiated
176  *      relative to an absolute time.
177  *
178  * Note that Postgres uses "time interval" to mean a bounded interval,
179  *      consisting of a beginning and ending time, not a time span - thomas 97/03/20
180  */
181
182 typedef double DateTime;
183
184 typedef struct
185 {
186         double          time;                   /* all time units other than months and
187                                                                  * years */
188         int             month;                  /* months and years, after time for
189                                                                  * alignment */
190 } TimeSpan;
191
192
193 /* ----------------------------------------------------------------
194  *                              time types + support macros
195  *
196  * String definitions for standard time quantities.
197  *
198  * These strings are the defaults used to form output time strings.
199  * Other alternate forms are hardcoded into token tables in dt.c.
200  * ----------------------------------------------------------------
201  */
202
203 #define DAGO                    "ago"
204 #define DCURRENT                "current"
205 #define EPOCH                   "epoch"
206 #define INVALID                 "invalid"
207 #define EARLY                   "-infinity"
208 #define LATE                    "infinity"
209 #define NOW                             "now"
210 #define TODAY                   "today"
211 #define TOMORROW                "tomorrow"
212 #define YESTERDAY               "yesterday"
213 #define ZULU                    "zulu"
214
215 #define DMICROSEC               "usecond"
216 #define DMILLISEC               "msecond"
217 #define DSECOND                 "second"
218 #define DMINUTE                 "minute"
219 #define DHOUR                   "hour"
220 #define DDAY                    "day"
221 #define DWEEK                   "week"
222 #define DMONTH                  "month"
223 #define DQUARTER                "quarter"
224 #define DYEAR                   "year"
225 #define DDECADE                 "decade"
226 #define DCENTURY                "century"
227 #define DMILLENIUM              "millenium"
228 #define DA_D                    "ad"
229 #define DB_C                    "bc"
230 #define DTIMEZONE               "timezone"
231
232 /*
233  * Fundamental time field definitions for parsing.
234  *
235  *      Meridian:  am, pm, or 24-hour style.
236  *      Millenium: ad, bc
237  */
238
239 #define AM              0
240 #define PM              1
241 #define HR24    2
242
243 #define AD              0
244 #define BC              1
245
246 /*
247  * Fields for time decoding.
248  * Can't have more of these than there are bits in an unsigned int
249  *      since these are turned into bit masks during parsing and decoding.
250  */
251
252 #define RESERV  0
253 #define MONTH   1
254 #define YEAR    2
255 #define DAY             3
256 #define TIMES   4                               /* not used - thomas 1997-07-14 */
257 #define TZ              5
258 #define DTZ             6
259 #define DTZMOD  7
260 #define IGNOREFIELD     8
261 #define AMPM    9
262 #define HOUR    10
263 #define MINUTE  11
264 #define SECOND  12
265 #define DOY             13
266 #define DOW             14
267 #define UNITS   15
268 #define ADBC    16
269 /* these are only for relative dates */
270 #define AGO             17
271 #define ABS_BEFORE              18
272 #define ABS_AFTER               19
273
274 /*
275  * Token field definitions for time parsing and decoding.
276  * These need to fit into the datetkn table type.
277  * At the moment, that means keep them within [-127,127].
278  * These are also used for bit masks in DecodeDateDelta()
279  *      so actually restrict them to within [0,31] for now.
280  * - thomas 97/06/19
281  * Not all of these fields are used for masks in DecodeDateDelta
282  *      so allow some larger than 31. - thomas 1997-11-17
283  */
284
285 #define DTK_NUMBER              0
286 #define DTK_STRING              1
287
288 #define DTK_DATE                2
289 #define DTK_TIME                3
290 #define DTK_TZ                  4
291 #define DTK_AGO                 5
292
293 #define DTK_SPECIAL             6
294 #define DTK_INVALID             7
295 #define DTK_CURRENT             8
296 #define DTK_EARLY               9
297 #define DTK_LATE                10
298 #define DTK_EPOCH               11
299 #define DTK_NOW                 12
300 #define DTK_YESTERDAY   13
301 #define DTK_TODAY               14
302 #define DTK_TOMORROW    15
303 #define DTK_ZULU                16
304
305 #define DTK_DELTA               17
306 #define DTK_SECOND              18
307 #define DTK_MINUTE              19
308 #define DTK_HOUR                20
309 #define DTK_DAY                 21
310 #define DTK_WEEK                22
311 #define DTK_MONTH               23
312 #define DTK_QUARTER             24
313 #define DTK_YEAR                25
314 #define DTK_DECADE              26
315 #define DTK_CENTURY             27
316 #define DTK_MILLENIUM   28
317 #define DTK_MILLISEC    29
318 #define DTK_MICROSEC    30
319
320 #define DTK_DOW                 32
321 #define DTK_DOY                 33
322 #define DTK_TZ_HOUR             34
323 #define DTK_TZ_MINUTE   35
324
325 /*
326  * Bit mask definitions for time parsing.
327  */
328
329 #define DTK_M(t)                (0x01 << (t))
330
331 #define DTK_DATE_M              (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
332 #define DTK_TIME_M              (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND))
333
334 #define MAXDATELEN              47              /* maximum possible length of an input
335                                                                  * date string */
336 #define MAXDATEFIELDS   25              /* maximum possible number of fields in a
337                                                                  * date string */
338 #define TOKMAXLEN               10              /* only this many chars are stored in
339                                                                  * datetktbl */
340
341 /* keep this struct small; it gets used a lot */
342 typedef struct
343 {
344 #if defined(_AIX)
345         char       *token;
346 #else
347         char            token[TOKMAXLEN];
348 #endif   /* _AIX */
349         char            type;
350         char            value;                  /* this may be unsigned, alas */
351 } datetkn;
352
353
354
355 /*
356  * dt.c prototypes
357  */
358
359
360 void j2date(int jd, int *year, int *month, int *day);
361 int     date2j(int year, int month, int day);
362
363 int ParseDateTime(char *timestr, char *lowstr,
364                           char **field, int *ftype, int maxfields, int *numfields);
365 int DecodeDateTime(char **field, int *ftype,
366                          int nf, int *dtype, struct tm * tm, double *fsec, int *tzp);
367
368 int DecodeTimeOnly(char **field, int *ftype, int nf,
369                            int *dtype, struct tm * tm, double *fsec);
370
371
372 #endif   /* DT_H */