Implemented Rtl*ByteSwap() functions, based on a patch by Jon
[wine/multimedia.git] / dlls / oleaut32 / parsedt.h
blob01b614ab077580ae0b341cf908236f18305b9b6b
1 /*
2 PostgreSQL Data Base Management System (formerly known as Postgres, then
3 as Postgres95).
5 Copyright (c) 1994-7 Regents of the University of California
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.
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.
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.
24 /*-------------------------------------------------------------------------
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.
32 * Copyright (c) 1994, Regents of the University of California
34 *-------------------------------------------------------------------------
36 #ifndef DT_H
37 #define DT_H
39 #include <time.h>
40 #include <math.h>
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.
47 #include <stdlib.h>
48 #include "windef.h" /* DateToTm use */
50 /* ----------------------------------------------------------------
51 * Section 1: bool, true, false, TRUE, FALSE
52 * ----------------------------------------------------------------
55 * bool --
56 * Boolean value, either true or false.
59 #define false ((char) 0)
60 #define true ((char) 1)
61 #ifndef __cplusplus
62 #ifndef bool
63 typedef char bool;
64 #endif /* ndef bool */
65 #endif /* not C++ */
66 typedef bool *BoolPtr;
68 #ifndef TRUE
69 #define TRUE 1
70 #endif /* TRUE */
72 #ifndef FALSE
73 #define FALSE 0
74 #endif /* FALSE */
78 /* ----------------------------------------------------------------
79 * Section 3: standard system types
80 * ----------------------------------------------------------------
84 * intN --
85 * Signed integer, EXACTLY N BITS IN SIZE,
86 * used for numerical computations and the
87 * frontend/backend protocol.
89 typedef signed char int8; /* == 8 bits */
90 typedef signed short int16; /* == 16 bits */
91 typedef signed int int32; /* == 32 bits */
94 * uintN --
95 * Unsigned integer, EXACTLY N BITS IN SIZE,
96 * used for numerical computations and the
97 * frontend/backend protocol.
99 typedef unsigned char uint8; /* == 8 bits */
100 typedef unsigned short uint16; /* == 16 bits */
101 typedef unsigned int uint32; /* == 32 bits */
104 * floatN --
105 * Floating point number, AT LEAST N BITS IN SIZE,
106 * used for numerical computations.
108 * Since sizeof(floatN) may be > sizeof(char *), always pass
109 * floatN by reference.
111 typedef float float32data;
112 typedef double float64data;
113 typedef float *float32;
114 typedef double *float64;
117 * boolN --
118 * Boolean value, AT LEAST N BITS IN SIZE.
120 typedef uint8 bool8; /* >= 8 bits */
121 typedef uint16 bool16; /* >= 16 bits */
122 typedef uint32 bool32; /* >= 32 bits */
125 /* Date/Time Configuration
127 * Constants to pass info from runtime environment:
128 * USE_POSTGRES_DATES specifies traditional postgres format for output.
129 * USE_ISO_DATES specifies ISO-compliant format for output.
130 * USE_SQL_DATES specified Oracle/Ingres-compliant format for output.
131 * USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
133 * DateStyle specifies preference for date formatting for output.
134 * EuroDates if client prefers dates interpreted and written w/European conventions.
136 * HasCTZSet if client timezone is specified by client.
137 * CDayLight is the apparent daylight savings time status.
138 * CTimeZone is the timezone offset in seconds.
139 * CTZName is the timezone label.
142 #define USE_POSTGRES_DATES 0
143 #define USE_ISO_DATES 1
144 #define USE_SQL_DATES 2
145 #define USE_GERMAN_DATES 3
147 extern int DateStyle;
148 extern bool EuroDates;
149 extern int CTimeZone;
151 typedef double float8;
153 struct varlena
155 int vl_len;
156 char vl_dat[1];
159 typedef struct varlena text;
163 typedef int AbsoluteTime;
164 typedef int RelativeTime;
167 * Note a leap year is one that is a multiple of 4
168 * but not of a 100. Except if it is a multiple of
169 * 400 then it is a leap year.
171 #define isleap(y) (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
174 * DateTime represents absolute time.
175 * TimeSpan represents delta time. Keep track of months (and years)
176 * separately since the elapsed time spanned is unknown until instantiated
177 * relative to an absolute time.
179 * Note that Postgres uses "time interval" to mean a bounded interval,
180 * consisting of a beginning and ending time, not a time span - thomas 97/03/20
183 typedef double DateTime;
185 typedef struct
187 double time; /* all time units other than months and
188 * years */
189 int month; /* months and years, after time for
190 * alignment */
191 } TimeSpan;
194 /* ----------------------------------------------------------------
195 * time types + support macros
197 * String definitions for standard time quantities.
199 * These strings are the defaults used to form output time strings.
200 * Other alternate forms are hardcoded into token tables in dt.c.
201 * ----------------------------------------------------------------
204 #define DAGO "ago"
205 #define DCURRENT "current"
206 #define EPOCH "epoch"
207 #define INVALID "invalid"
208 #define EARLY "-infinity"
209 #define LATE "infinity"
210 #define NOW "now"
211 #define TODAY "today"
212 #define TOMORROW "tomorrow"
213 #define YESTERDAY "yesterday"
214 #define ZULU "zulu"
216 #define DMICROSEC "usecond"
217 #define DMILLISEC "msecond"
218 #define DSECOND "second"
219 #define DMINUTE "minute"
220 #define DHOUR "hour"
221 #define DDAY "day"
222 #define DWEEK "week"
223 #define DMONTH "month"
224 #define DQUARTER "quarter"
225 #define DYEAR "year"
226 #define DDECADE "decade"
227 #define DCENTURY "century"
228 #define DMILLENIUM "millenium"
229 #define DA_D "ad"
230 #define DB_C "bc"
231 #define DTIMEZONE "timezone"
234 * Fundamental time field definitions for parsing.
236 * Meridian: am, pm, or 24-hour style.
237 * Millenium: ad, bc
240 #define AM 0
241 #define PM 1
242 #define HR24 2
244 #define AD 0
245 #define BC 1
248 * Fields for time decoding.
249 * Can't have more of these than there are bits in an unsigned int
250 * since these are turned into bit masks during parsing and decoding.
253 #define RESERV 0
254 #define MONTH 1
255 #define YEAR 2
256 #define DAY 3
257 #define TIMES 4 /* not used - thomas 1997-07-14 */
258 #define TZ 5
259 #define DTZ 6
260 #define DTZMOD 7
261 #define IGNOREFIELD 8
262 #define AMPM 9
263 #define HOUR 10
264 #define MINUTE 11
265 #define SECOND 12
266 #define DOY 13
267 #define DOW 14
268 #define UNITS 15
269 #define ADBC 16
270 /* these are only for relative dates */
271 #define AGO 17
272 #define ABS_BEFORE 18
273 #define ABS_AFTER 19
276 * Token field definitions for time parsing and decoding.
277 * These need to fit into the datetkn table type.
278 * At the moment, that means keep them within [-127,127].
279 * These are also used for bit masks in DecodeDateDelta()
280 * so actually restrict them to within [0,31] for now.
281 * - thomas 97/06/19
282 * Not all of these fields are used for masks in DecodeDateDelta
283 * so allow some larger than 31. - thomas 1997-11-17
286 #define DTK_NUMBER 0
287 #define DTK_STRING 1
289 #define DTK_DATE 2
290 #define DTK_TIME 3
291 #define DTK_TZ 4
292 #define DTK_AGO 5
294 #define DTK_SPECIAL 6
295 #define DTK_INVALID 7
296 #define DTK_CURRENT 8
297 #define DTK_EARLY 9
298 #define DTK_LATE 10
299 #define DTK_EPOCH 11
300 #define DTK_NOW 12
301 #define DTK_YESTERDAY 13
302 #define DTK_TODAY 14
303 #define DTK_TOMORROW 15
304 #define DTK_ZULU 16
306 #define DTK_DELTA 17
307 #define DTK_SECOND 18
308 #define DTK_MINUTE 19
309 #define DTK_HOUR 20
310 #define DTK_DAY 21
311 #define DTK_WEEK 22
312 #define DTK_MONTH 23
313 #define DTK_QUARTER 24
314 #define DTK_YEAR 25
315 #define DTK_DECADE 26
316 #define DTK_CENTURY 27
317 #define DTK_MILLENIUM 28
318 #define DTK_MILLISEC 29
319 #define DTK_MICROSEC 30
321 #define DTK_DOW 32
322 #define DTK_DOY 33
323 #define DTK_TZ_HOUR 34
324 #define DTK_TZ_MINUTE 35
327 * Bit mask definitions for time parsing.
330 #define DTK_M(t) (0x01 << (t))
332 #define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
333 #define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND))
335 #define MAXDATELEN 47 /* maximum possible length of an input
336 * date string */
337 #define MAXDATEFIELDS 25 /* maximum possible number of fields in a
338 * date string */
339 #define TOKMAXLEN 10 /* only this many chars are stored in
340 * datetktbl */
342 /* keep this struct small; it gets used a lot */
343 typedef struct
345 #if defined(_AIX)
346 char *token;
347 #else
348 char token[TOKMAXLEN];
349 #endif /* _AIX */
350 char type;
351 char value; /* this may be unsigned, alas */
352 } datetkn;
357 * dt.c prototypes
361 void j2date(int jd, int *year, int *month, int *day);
362 int date2j(int year, int month, int day);
364 int ParseDateTime(char *timestr, char *lowstr,
365 char **field, int *ftype, int maxfields, int *numfields);
366 int DecodeDateTime(char **field, int *ftype,
367 int nf, int *dtype, struct tm * tm, double *fsec, int *tzp);
369 int DecodeTimeOnly(char **field, int *ftype, int nf,
370 int *dtype, struct tm * tm, double *fsec);
371 BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm );
372 #endif /* DT_H */