source: trunk/src/oleaut32/parsedt.h@ 1036

Last change on this file since 1036 was 632, checked in by sandervl, 26 years ago

Created (WINE Port of OLEAUT32)

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