Add guard code to protect from buffer overruns on long date/time input
strings. Should go back in and look at doing this a bit more elegantly and (hopefully) cheaper. Probably not too bad anyway, but it seems a shame to scan the strings twice: once for length for this buffer overrun protection, and once to parse the line. Remove use of pow() in date/time handling; was already gone from everything *but* the time data types. Define macros for handling typmod manipulation for date/time types. Should be more robust than all of that brute-force inline code. Rename macros for masking and typmod manipulation to put TIMESTAMP_ or INTERVAL_ in front of the macro name, to reduce the possibility of name space collisions.
This commit is contained in:
parent
e025bb7a72
commit
b71310d8e0
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.69 2002/06/20 20:29:36 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.70 2002/08/04 06:44:47 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -57,6 +57,9 @@ date_in(PG_FUNCTION_ARGS)
|
|||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + 1];
|
||||||
|
|
||||||
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
|
elog(ERROR, "Bad date external representation (too long) '%s'", str);
|
||||||
|
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tzp) != 0))
|
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tzp) != 0))
|
||||||
elog(ERROR, "Bad date external representation '%s'", str);
|
elog(ERROR, "Bad date external representation '%s'", str);
|
||||||
@ -518,6 +521,9 @@ time_in(PG_FUNCTION_ARGS)
|
|||||||
int dtype;
|
int dtype;
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
|
|
||||||
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
|
elog(ERROR, "Bad time external representation (too long) '%s'", str);
|
||||||
|
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||||
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, NULL) != 0))
|
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, NULL) != 0))
|
||||||
elog(ERROR, "Bad time external representation '%s'", str);
|
elog(ERROR, "Bad time external representation '%s'", str);
|
||||||
@ -606,37 +612,85 @@ time_scale(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_TIMEADT(result);
|
PG_RETURN_TIMEADT(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* AdjustTimeForTypmod()
|
||||||
|
* Force the precision of the time value to a specified value.
|
||||||
|
* Uses *exactly* the same code as in AdjustTimestampForTypemod()
|
||||||
|
* but we make a separate copy because those types do not
|
||||||
|
* have a fundamental tie together but rather a coincidence of
|
||||||
|
* implementation. - thomas
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
AdjustTimeForTypmod(TimeADT *time, int32 typmod)
|
AdjustTimeForTypmod(TimeADT *time, int32 typmod)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
|
static const int64 TimeScales[MAX_TIMESTAMP_PRECISION+1] = {
|
||||||
|
INT64CONST(1000000),
|
||||||
|
INT64CONST(100000),
|
||||||
|
INT64CONST(10000),
|
||||||
|
INT64CONST(1000),
|
||||||
|
INT64CONST(100),
|
||||||
|
INT64CONST(10),
|
||||||
|
INT64CONST(1)
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int64 TimeOffsets[MAX_TIMESTAMP_PRECISION+1] = {
|
||||||
|
INT64CONST(-500000),
|
||||||
|
INT64CONST(-50000),
|
||||||
|
INT64CONST(-5000),
|
||||||
|
INT64CONST(-500),
|
||||||
|
INT64CONST(-50),
|
||||||
|
INT64CONST(-5),
|
||||||
|
INT64CONST(0)
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
static const double TimeScales[MAX_TIMESTAMP_PRECISION+1] = {
|
||||||
|
1,
|
||||||
|
10,
|
||||||
|
100,
|
||||||
|
1000,
|
||||||
|
10000,
|
||||||
|
100000,
|
||||||
|
1000000
|
||||||
|
};
|
||||||
|
|
||||||
|
static const double TimeOffsets[MAX_TIMESTAMP_PRECISION+1] = {
|
||||||
|
0.5,
|
||||||
|
0.05,
|
||||||
|
0.005,
|
||||||
|
0.0005,
|
||||||
|
0.00005,
|
||||||
|
0.000005,
|
||||||
|
0.0000005
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((typmod >= 0) && (typmod <= MAX_TIME_PRECISION))
|
if ((typmod >= 0) && (typmod <= MAX_TIME_PRECISION))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
static int64 TimeScale = INT64CONST(1000000);
|
/* we have different truncation behavior depending on sign */
|
||||||
#else
|
if (*time >= INT64CONST(0))
|
||||||
static double TimeScale = 1;
|
|
||||||
#endif
|
|
||||||
static int32 TimeTypmod = 0;
|
|
||||||
|
|
||||||
if (typmod != TimeTypmod)
|
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
*time = ((*time / TimeScales[typmod])
|
||||||
TimeScale = pow(10.0, (MAX_TIME_PRECISION-typmod));
|
* TimeScales[typmod]);
|
||||||
#else
|
}
|
||||||
TimeScale = pow(10.0, typmod);
|
else
|
||||||
#endif
|
{
|
||||||
TimeTypmod = typmod;
|
*time = (((*time + TimeOffsets[typmod]) / TimeScales[typmod])
|
||||||
|
* TimeScales[typmod]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
|
||||||
*time = ((*time / TimeScale) * TimeScale);
|
|
||||||
if (*time >= INT64CONST(86400000000))
|
|
||||||
*time -= INT64CONST(86400000000);
|
|
||||||
#else
|
#else
|
||||||
*time = (rint(((double) *time) * TimeScale) / TimeScale);
|
/* we have different truncation behavior depending on sign */
|
||||||
|
if (*time >= 0)
|
||||||
if (*time >= 86400)
|
{
|
||||||
*time -= 86400;
|
*time = (rint(((double) *time) * TimeScales[typmod])
|
||||||
|
/ TimeScales[typmod]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Scale and truncate first, then add to help the rounding behavior */
|
||||||
|
*time = (rint((((double) *time) * TimeScales[typmod]) + TimeOffsets[typmod])
|
||||||
|
/ TimeScales[typmod]);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1269,6 +1323,10 @@ timetz_in(PG_FUNCTION_ARGS)
|
|||||||
int dtype;
|
int dtype;
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
|
|
||||||
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
|
elog(ERROR, "Bad time with time zone"
|
||||||
|
" external representation (too long) '%s'", str);
|
||||||
|
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||||
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
||||||
elog(ERROR, "Bad time external representation '%s'", str);
|
elog(ERROR, "Bad time external representation '%s'", str);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.92 2002/06/20 20:29:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.93 2002/08/04 06:44:47 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -56,21 +56,31 @@ char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
|
|||||||
* PRIVATE ROUTINES *
|
* PRIVATE ROUTINES *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/* definitions for squeezing values into "value" */
|
/*
|
||||||
|
* Definitions for squeezing values into "value"
|
||||||
|
* We set aside a high bit for a sign, and scale the timezone offsets
|
||||||
|
* in minutes by a factor of 15 (so can represent quarter-hour increments).
|
||||||
|
*/
|
||||||
#define ABS_SIGNBIT ((char) 0200)
|
#define ABS_SIGNBIT ((char) 0200)
|
||||||
#define VALMASK ((char) 0177)
|
#define VALMASK ((char) 0177)
|
||||||
|
#define POS(n) (n)
|
||||||
#define NEG(n) ((n)|ABS_SIGNBIT)
|
#define NEG(n) ((n)|ABS_SIGNBIT)
|
||||||
#define SIGNEDCHAR(c) ((c)&ABS_SIGNBIT? -((c)&VALMASK): (c))
|
#define SIGNEDCHAR(c) ((c)&ABS_SIGNBIT? -((c)&VALMASK): (c))
|
||||||
#define FROMVAL(tp) (-SIGNEDCHAR((tp)->value) * 10) /* uncompress */
|
#define FROMVAL(tp) (-SIGNEDCHAR((tp)->value) * 15) /* uncompress */
|
||||||
#define TOVAL(tp, v) ((tp)->value = ((v) < 0? NEG((-(v))/10): (v)/10))
|
#define TOVAL(tp, v) ((tp)->value = ((v) < 0? NEG((-(v))/15): POS(v)/15))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* datetktbl holds date/time keywords. Note that this table must be strictly
|
* datetktbl holds date/time keywords. Note that this table must be strictly
|
||||||
* ordered to allow an O(ln(N)) search algorithm.
|
* ordered to allow an O(ln(N)) search algorithm.
|
||||||
*
|
*
|
||||||
|
* The text field is not guaranteed to be NULL-terminated.
|
||||||
|
*
|
||||||
* To keep this table reasonably small, we divide the lexval for TZ and DTZ
|
* To keep this table reasonably small, we divide the lexval for TZ and DTZ
|
||||||
* entries by 10 and truncate the text field at MAXTOKLEN characters.
|
* entries by 15 (so they are on 15 minute boundaries) and truncate the text
|
||||||
* the text field is not guaranteed to be NULL-terminated.
|
* field at MAXTOKLEN characters.
|
||||||
|
* Formerly, we divided by 10 rather than 15 but there are a few time zones
|
||||||
|
* which are 30 or 45 minutes away from an even hour, most are on an hour
|
||||||
|
* boundary, and none on other boundaries.
|
||||||
*
|
*
|
||||||
* Let's include all strings from my current zinc time zone database.
|
* Let's include all strings from my current zinc time zone database.
|
||||||
* Not all of them are unique, or even very understandable, so we will
|
* Not all of them are unique, or even very understandable, so we will
|
||||||
@ -79,414 +89,415 @@ char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
|
|||||||
static datetkn datetktbl[] = {
|
static datetkn datetktbl[] = {
|
||||||
/* text, token, lexval */
|
/* text, token, lexval */
|
||||||
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
|
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
|
||||||
{"acsst", DTZ, 63}, /* Cent. Australia */
|
{"acsst", DTZ, POS(42)}, /* Cent. Australia */
|
||||||
{"acst", DTZ, NEG(24)}, /* Atlantic/Porto Acre */
|
{"acst", DTZ, NEG(16)}, /* Atlantic/Porto Acre */
|
||||||
{"act", TZ, NEG(30)}, /* Atlantic/Porto Acre */
|
{"act", TZ, NEG(20)}, /* Atlantic/Porto Acre */
|
||||||
{DA_D, ADBC, AD}, /* "ad" for years >= 0 */
|
{DA_D, ADBC, AD}, /* "ad" for years >= 0 */
|
||||||
{"abstime", IGNORE_DTF, 0}, /* for pre-v6.1 "Invalid Abstime" */
|
{"abstime", IGNORE_DTF, 0}, /* for pre-v6.1 "Invalid Abstime" */
|
||||||
{"adt", DTZ, NEG(18)}, /* Atlantic Daylight Time */
|
{"adt", DTZ, NEG(12)}, /* Atlantic Daylight Time */
|
||||||
{"aesst", DTZ, 66}, /* E. Australia */
|
{"aesst", DTZ, POS(44)}, /* E. Australia */
|
||||||
{"aest", TZ, 60}, /* Australia Eastern Std Time */
|
{"aest", TZ, POS(40)}, /* Australia Eastern Std Time */
|
||||||
{"aft", TZ, 27}, /* Kabul */
|
{"aft", TZ, POS(18)}, /* Kabul */
|
||||||
{"ahst", TZ, NEG(60)}, /* Alaska-Hawaii Std Time */
|
{"ahst", TZ, NEG(40)}, /* Alaska-Hawaii Std Time */
|
||||||
{"akdt", DTZ, NEG(48)}, /* Alaska Daylight Time */
|
{"akdt", DTZ, NEG(32)}, /* Alaska Daylight Time */
|
||||||
{"akst", DTZ, NEG(54)}, /* Alaska Standard Time */
|
{"akst", DTZ, NEG(36)}, /* Alaska Standard Time */
|
||||||
{"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */
|
{"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */
|
||||||
{"almt", TZ, 36}, /* Almaty Time */
|
{"almt", TZ, POS(24)}, /* Almaty Time */
|
||||||
{"almst", TZ, 42}, /* Almaty Savings Time */
|
{"almst", TZ, POS(28)}, /* Almaty Savings Time */
|
||||||
{"am", AMPM, AM},
|
{"am", AMPM, AM},
|
||||||
{"amst", DTZ, 30}, /* Armenia Summer Time (Yerevan) */
|
{"amst", DTZ, POS(20)}, /* Armenia Summer Time (Yerevan) */
|
||||||
{"amt", TZ, 24}, /* Armenia Time (Yerevan) */
|
{"amt", TZ, POS(16)}, /* Armenia Time (Yerevan) */
|
||||||
#if 0
|
#if 0
|
||||||
{"amst", DTZ, NEG(18)}, /* Porto Velho */
|
{"amst", DTZ, NEG(12)}, /* Porto Velho */
|
||||||
#endif
|
#endif
|
||||||
{"anast", DTZ, 78}, /* Anadyr Summer Time (Russia) */
|
{"anast", DTZ, POS(52)}, /* Anadyr Summer Time (Russia) */
|
||||||
{"anat", TZ, 72}, /* Anadyr Time (Russia) */
|
{"anat", TZ, POS(48)}, /* Anadyr Time (Russia) */
|
||||||
#if 0
|
#if 0
|
||||||
aqtst
|
aqtst
|
||||||
aqtt
|
aqtt
|
||||||
arst
|
arst
|
||||||
#endif
|
#endif
|
||||||
{"art", TZ, NEG(18)}, /* Argentina Time */
|
{"art", TZ, NEG(12)}, /* Argentina Time */
|
||||||
#if 0
|
#if 0
|
||||||
ashst
|
ashst
|
||||||
ast /* Atlantic Standard Time, Arabia Standard Time, Acre Standard Time */
|
ast /* Atlantic Standard Time, Arabia Standard Time, Acre Standard Time */
|
||||||
#endif
|
#endif
|
||||||
{"apr", MONTH, 4},
|
{"apr", MONTH, 4},
|
||||||
{"april", MONTH, 4},
|
{"april", MONTH, 4},
|
||||||
{"ast", TZ, NEG(24)}, /* Atlantic Std Time (Canada) */
|
{"ast", TZ, NEG(16)}, /* Atlantic Std Time (Canada) */
|
||||||
{"at", IGNORE_DTF, 0}, /* "at" (throwaway) */
|
{"at", IGNORE_DTF, 0}, /* "at" (throwaway) */
|
||||||
{"aug", MONTH, 8},
|
{"aug", MONTH, 8},
|
||||||
{"august", MONTH, 8},
|
{"august", MONTH, 8},
|
||||||
{"awsst", DTZ, 54}, /* W. Australia */
|
{"awsst", DTZ, POS(36)}, /* W. Australia */
|
||||||
{"awst", TZ, 48}, /* W. Australia */
|
{"awst", TZ, POS(32)}, /* W. Australia */
|
||||||
{"awt", DTZ, NEG(18)},
|
{"awt", DTZ, NEG(12)},
|
||||||
{"azost", DTZ, 0}, /* Azores Summer Time */
|
{"azost", DTZ, POS(0)}, /* Azores Summer Time */
|
||||||
{"azot", TZ, NEG(6)}, /* Azores Time */
|
{"azot", TZ, NEG(4)}, /* Azores Time */
|
||||||
{"azst", DTZ, 30}, /* Azerbaijan Summer Time */
|
{"azst", DTZ, POS(20)}, /* Azerbaijan Summer Time */
|
||||||
{"azt", TZ, 24}, /* Azerbaijan Time */
|
{"azt", TZ, POS(16)}, /* Azerbaijan Time */
|
||||||
{DB_C, ADBC, BC}, /* "bc" for years < 0 */
|
{DB_C, ADBC, BC}, /* "bc" for years < 0 */
|
||||||
{"bdst", TZ, 12}, /* British Double Summer Time */
|
{"bdst", TZ, POS(8)}, /* British Double Summer Time */
|
||||||
{"bdt", TZ, 36}, /* Dacca */
|
{"bdt", TZ, POS(24)}, /* Dacca */
|
||||||
{"bnt", TZ, 48}, /* Brunei Darussalam Time */
|
{"bnt", TZ, POS(32)}, /* Brunei Darussalam Time */
|
||||||
{"bort", TZ, 48}, /* Borneo Time (Indonesia) */
|
{"bort", TZ, POS(32)}, /* Borneo Time (Indonesia) */
|
||||||
#if 0
|
#if 0
|
||||||
bortst
|
bortst
|
||||||
bost
|
bost
|
||||||
#endif
|
#endif
|
||||||
{"bot", TZ, NEG(24)}, /* Bolivia Time */
|
{"bot", TZ, NEG(16)}, /* Bolivia Time */
|
||||||
{"bra", TZ, NEG(18)}, /* Brazil Time */
|
{"bra", TZ, NEG(12)}, /* Brazil Time */
|
||||||
#if 0
|
#if 0
|
||||||
brst
|
brst
|
||||||
brt
|
brt
|
||||||
#endif
|
#endif
|
||||||
{"bst", DTZ, 6}, /* British Summer Time */
|
{"bst", DTZ, POS(4)}, /* British Summer Time */
|
||||||
#if 0
|
#if 0
|
||||||
{"bst", TZ, NEG(18)}, /* Brazil Standard Time */
|
{"bst", TZ, NEG(12)}, /* Brazil Standard Time */
|
||||||
{"bst", DTZ, NEG(66)}, /* Bering Summer Time */
|
{"bst", DTZ, NEG(44)}, /* Bering Summer Time */
|
||||||
#endif
|
#endif
|
||||||
{"bt", TZ, 18}, /* Baghdad Time */
|
{"bt", TZ, POS(12)}, /* Baghdad Time */
|
||||||
{"btt", TZ, 36}, /* Bhutan Time */
|
{"btt", TZ, POS(24)}, /* Bhutan Time */
|
||||||
{"cadt", DTZ, 63}, /* Central Australian DST */
|
{"cadt", DTZ, POS(42)}, /* Central Australian DST */
|
||||||
{"cast", TZ, 57}, /* Central Australian ST */
|
{"cast", TZ, POS(38)}, /* Central Australian ST */
|
||||||
{"cat", TZ, NEG(60)}, /* Central Alaska Time */
|
{"cat", TZ, NEG(40)}, /* Central Alaska Time */
|
||||||
{"cct", TZ, 48}, /* China Coast Time */
|
{"cct", TZ, POS(32)}, /* China Coast Time */
|
||||||
#if 0
|
#if 0
|
||||||
{"cct", TZ, 39}, /* Indian Cocos (Island) Time */
|
{"cct", TZ, POS(26)}, /* Indian Cocos (Island) Time */
|
||||||
#endif
|
#endif
|
||||||
{"cdt", DTZ, NEG(30)}, /* Central Daylight Time */
|
{"cdt", DTZ, NEG(20)}, /* Central Daylight Time */
|
||||||
{"cest", DTZ, 12}, /* Central European Dayl.Time */
|
{"cest", DTZ, POS(8)}, /* Central European Dayl.Time */
|
||||||
{"cet", TZ, 6}, /* Central European Time */
|
{"cet", TZ, POS(4)}, /* Central European Time */
|
||||||
{"cetdst", DTZ, 12}, /* Central European Dayl.Time */
|
{"cetdst", DTZ, POS(8)}, /* Central European Dayl.Time */
|
||||||
|
{"chadt", DTZ, POS(55)}, /* Chatham Island Daylight Time (13:45) */
|
||||||
|
{"chast", TZ, POS(51)}, /* Chatham Island Time (12:45) */
|
||||||
#if 0
|
#if 0
|
||||||
{"chadt", DTZ, 82}, /* Chatham Island Daylight Time (13:45? set to 13:40) */
|
|
||||||
{"chast", TZ, 76}, /* Chatham Island Time (12:45? set to 12:40) */
|
|
||||||
ckhst
|
ckhst
|
||||||
#endif
|
#endif
|
||||||
{"ckt", TZ, 72}, /* Cook Islands Time */
|
{"ckt", TZ, POS(48)}, /* Cook Islands Time */
|
||||||
{"clst", DTZ, NEG(18)}, /* Chile Summer Time */
|
{"clst", DTZ, NEG(12)}, /* Chile Summer Time */
|
||||||
{"clt", TZ, NEG(24)}, /* Chile Time */
|
{"clt", TZ, NEG(16)}, /* Chile Time */
|
||||||
#if 0
|
#if 0
|
||||||
cost
|
cost
|
||||||
#endif
|
#endif
|
||||||
{"cot", TZ, NEG(30)}, /* Columbia Time */
|
{"cot", TZ, NEG(20)}, /* Columbia Time */
|
||||||
{"cst", TZ, NEG(36)}, /* Central Standard Time */
|
{"cst", TZ, NEG(24)}, /* Central Standard Time */
|
||||||
#if 0
|
#if 0
|
||||||
cvst
|
cvst
|
||||||
#endif
|
#endif
|
||||||
{"cvt", TZ, 42}, /* Christmas Island Time (Indian Ocean) */
|
{"cvt", TZ, POS(28)}, /* Christmas Island Time (Indian Ocean) */
|
||||||
{"cxt", TZ, 42}, /* Christmas Island Time (Indian Ocean) */
|
{"cxt", TZ, POS(28)}, /* Christmas Island Time (Indian Ocean) */
|
||||||
{DCURRENT, RESERV, DTK_CURRENT}, /* "current" is always now */
|
{DCURRENT, RESERV, DTK_CURRENT}, /* "current" is always now */
|
||||||
{"d", UNITS, DTK_DAY}, /* "day of month" for ISO input */
|
{"d", UNITS, DTK_DAY}, /* "day of month" for ISO input */
|
||||||
{"davt", TZ, 42}, /* Davis Time (Antarctica) */
|
{"davt", TZ, POS(28)}, /* Davis Time (Antarctica) */
|
||||||
{"ddut", TZ, 60}, /* Dumont-d'Urville Time (Antarctica) */
|
{"ddut", TZ, POS(40)}, /* Dumont-d'Urville Time (Antarctica) */
|
||||||
{"dec", MONTH, 12},
|
{"dec", MONTH, 12},
|
||||||
{"december", MONTH, 12},
|
{"december", MONTH, 12},
|
||||||
{"dnt", TZ, 6}, /* Dansk Normal Tid */
|
{"dnt", TZ, POS(4)}, /* Dansk Normal Tid */
|
||||||
{"dow", RESERV, DTK_DOW}, /* day of week */
|
{"dow", RESERV, DTK_DOW}, /* day of week */
|
||||||
{"doy", RESERV, DTK_DOY}, /* day of year */
|
{"doy", RESERV, DTK_DOY}, /* day of year */
|
||||||
{"dst", DTZMOD, 6},
|
{"dst", DTZMOD, 6},
|
||||||
#if 0
|
#if 0
|
||||||
{"dusst", DTZ, 36}, /* Dushanbe Summer Time */
|
{"dusst", DTZ, POS(24)}, /* Dushanbe Summer Time */
|
||||||
#endif
|
#endif
|
||||||
{"easst", DTZ, NEG(30)}, /* Easter Island Summer Time */
|
{"easst", DTZ, NEG(20)}, /* Easter Island Summer Time */
|
||||||
{"east", TZ, NEG(36)}, /* Easter Island Time */
|
{"east", TZ, NEG(24)}, /* Easter Island Time */
|
||||||
{"eat", TZ, 18}, /* East Africa Time */
|
{"eat", TZ, POS(12)}, /* East Africa Time */
|
||||||
#if 0
|
#if 0
|
||||||
{"east", DTZ, 24}, /* Indian Antananarivo Savings Time */
|
{"east", DTZ, POS(16)}, /* Indian Antananarivo Savings Time */
|
||||||
{"eat", TZ, 18}, /* Indian Antananarivo Time */
|
{"eat", TZ, POS(12)}, /* Indian Antananarivo Time */
|
||||||
{"ect", TZ, NEG(24)}, /* Eastern Caribbean Time */
|
{"ect", TZ, NEG(16)}, /* Eastern Caribbean Time */
|
||||||
{"ect", TZ, NEG(30)}, /* Ecuador Time */
|
{"ect", TZ, NEG(20)}, /* Ecuador Time */
|
||||||
#endif
|
#endif
|
||||||
{"edt", DTZ, NEG(24)}, /* Eastern Daylight Time */
|
{"edt", DTZ, NEG(16)}, /* Eastern Daylight Time */
|
||||||
{"eest", DTZ, 18}, /* Eastern Europe Summer Time */
|
{"eest", DTZ, POS(12)}, /* Eastern Europe Summer Time */
|
||||||
{"eet", TZ, 12}, /* East. Europe, USSR Zone 1 */
|
{"eet", TZ, POS(8)}, /* East. Europe, USSR Zone 1 */
|
||||||
{"eetdst", DTZ, 18}, /* Eastern Europe Daylight Time */
|
{"eetdst", DTZ, POS(12)}, /* Eastern Europe Daylight Time */
|
||||||
{"egst", DTZ, 0}, /* East Greenland Summer Time */
|
{"egst", DTZ, POS(0)}, /* East Greenland Summer Time */
|
||||||
{"egt", TZ, NEG(6)}, /* East Greenland Time */
|
{"egt", TZ, NEG(4)}, /* East Greenland Time */
|
||||||
#if 0
|
#if 0
|
||||||
ehdt
|
ehdt
|
||||||
#endif
|
#endif
|
||||||
{EPOCH, RESERV, DTK_EPOCH}, /* "epoch" reserved for system epoch time */
|
{EPOCH, RESERV, DTK_EPOCH}, /* "epoch" reserved for system epoch time */
|
||||||
{"est", TZ, NEG(30)}, /* Eastern Standard Time */
|
{"est", TZ, NEG(20)}, /* Eastern Standard Time */
|
||||||
{"feb", MONTH, 2},
|
{"feb", MONTH, 2},
|
||||||
{"february", MONTH, 2},
|
{"february", MONTH, 2},
|
||||||
{"fjst", DTZ, NEG(78)}, /* Fiji Summer Time (13 hour offset!) */
|
{"fjst", DTZ, NEG(52)}, /* Fiji Summer Time (13 hour offset!) */
|
||||||
{"fjt", TZ, NEG(72)}, /* Fiji Time */
|
{"fjt", TZ, NEG(48)}, /* Fiji Time */
|
||||||
{"fkst", DTZ, NEG(18)}, /* Falkland Islands Summer Time */
|
{"fkst", DTZ, NEG(12)}, /* Falkland Islands Summer Time */
|
||||||
{"fkt", TZ, NEG(12)}, /* Falkland Islands Time */
|
{"fkt", TZ, NEG(8)}, /* Falkland Islands Time */
|
||||||
#if 0
|
#if 0
|
||||||
fnst
|
fnst
|
||||||
fnt
|
fnt
|
||||||
#endif
|
#endif
|
||||||
{"fri", DOW, 5},
|
{"fri", DOW, 5},
|
||||||
{"friday", DOW, 5},
|
{"friday", DOW, 5},
|
||||||
{"fst", TZ, 6}, /* French Summer Time */
|
{"fst", TZ, POS(4)}, /* French Summer Time */
|
||||||
{"fwt", DTZ, 12}, /* French Winter Time */
|
{"fwt", DTZ, POS(8)}, /* French Winter Time */
|
||||||
{"galt", TZ, NEG(36)}, /* Galapagos Time */
|
{"galt", TZ, NEG(24)}, /* Galapagos Time */
|
||||||
{"gamt", TZ, NEG(54)}, /* Gambier Time */
|
{"gamt", TZ, NEG(36)}, /* Gambier Time */
|
||||||
{"gest", DTZ, 30}, /* Georgia Summer Time */
|
{"gest", DTZ, POS(20)}, /* Georgia Summer Time */
|
||||||
{"get", TZ, 24}, /* Georgia Time */
|
{"get", TZ, POS(16)}, /* Georgia Time */
|
||||||
{"gft", TZ, NEG(18)}, /* French Guiana Time */
|
{"gft", TZ, NEG(12)}, /* French Guiana Time */
|
||||||
#if 0
|
#if 0
|
||||||
ghst
|
ghst
|
||||||
#endif
|
#endif
|
||||||
{"gilt", TZ, 72}, /* Gilbert Islands Time */
|
{"gilt", TZ, POS(48)}, /* Gilbert Islands Time */
|
||||||
{"gmt", TZ, 0}, /* Greenwish Mean Time */
|
{"gmt", TZ, POS(0)}, /* Greenwish Mean Time */
|
||||||
{"gst", TZ, 60}, /* Guam Std Time, USSR Zone 9 */
|
{"gst", TZ, POS(40)}, /* Guam Std Time, USSR Zone 9 */
|
||||||
{"gyt", TZ, NEG(24)}, /* Guyana Time */
|
{"gyt", TZ, NEG(16)}, /* Guyana Time */
|
||||||
{"h", UNITS, DTK_HOUR}, /* "hour" */
|
{"h", UNITS, DTK_HOUR}, /* "hour" */
|
||||||
#if 0
|
#if 0
|
||||||
hadt
|
hadt
|
||||||
hast
|
hast
|
||||||
#endif
|
#endif
|
||||||
{"hdt", DTZ, NEG(54)}, /* Hawaii/Alaska Daylight Time */
|
{"hdt", DTZ, NEG(36)}, /* Hawaii/Alaska Daylight Time */
|
||||||
#if 0
|
#if 0
|
||||||
hkst
|
hkst
|
||||||
#endif
|
#endif
|
||||||
{"hkt", TZ, 48}, /* Hong Kong Time */
|
{"hkt", TZ, POS(32)}, /* Hong Kong Time */
|
||||||
#if 0
|
#if 0
|
||||||
{"hmt", TZ, 18}, /* Hellas ? ? */
|
{"hmt", TZ, POS(12)}, /* Hellas ? ? */
|
||||||
hovst
|
hovst
|
||||||
hovt
|
hovt
|
||||||
#endif
|
#endif
|
||||||
{"hst", TZ, NEG(60)}, /* Hawaii Std Time */
|
{"hst", TZ, NEG(40)}, /* Hawaii Std Time */
|
||||||
#if 0
|
#if 0
|
||||||
hwt
|
hwt
|
||||||
#endif
|
#endif
|
||||||
{"ict", TZ, 42}, /* Indochina Time */
|
{"ict", TZ, POS(28)}, /* Indochina Time */
|
||||||
{"idle", TZ, 72}, /* Intl. Date Line, East */
|
{"idle", TZ, POS(48)}, /* Intl. Date Line, East */
|
||||||
{"idlw", TZ, NEG(72)}, /* Intl. Date Line, West */
|
{"idlw", TZ, NEG(48)}, /* Intl. Date Line, West */
|
||||||
#if 0
|
#if 0
|
||||||
idt /* Israeli, Iran, Indian Daylight Time */
|
idt /* Israeli, Iran, Indian Daylight Time */
|
||||||
#endif
|
#endif
|
||||||
{LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */
|
{LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */
|
||||||
{INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for bad time */
|
{INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for bad time */
|
||||||
{"iot", TZ, 30}, /* Indian Chagos Time */
|
{"iot", TZ, POS(20)}, /* Indian Chagos Time */
|
||||||
{"irkst", DTZ, 54}, /* Irkutsk Summer Time */
|
{"irkst", DTZ, POS(36)}, /* Irkutsk Summer Time */
|
||||||
{"irkt", TZ, 48}, /* Irkutsk Time */
|
{"irkt", TZ, POS(32)}, /* Irkutsk Time */
|
||||||
{"irt", TZ, 21}, /* Iran Time */
|
{"irt", TZ, POS(14)}, /* Iran Time */
|
||||||
#if 0
|
#if 0
|
||||||
isst
|
isst
|
||||||
#endif
|
#endif
|
||||||
{"ist", TZ, 12}, /* Israel */
|
{"ist", TZ, POS(8)}, /* Israel */
|
||||||
{"it", TZ, 21}, /* Iran Time */
|
{"it", TZ, POS(14)}, /* Iran Time */
|
||||||
{"j", UNITS, DTK_JULIAN},
|
{"j", UNITS, DTK_JULIAN},
|
||||||
{"jan", MONTH, 1},
|
{"jan", MONTH, 1},
|
||||||
{"january", MONTH, 1},
|
{"january", MONTH, 1},
|
||||||
{"javt", TZ, 42}, /* Java Time (07:00? see JT) */
|
{"javt", TZ, POS(28)}, /* Java Time (07:00? see JT) */
|
||||||
{"jayt", TZ, 54}, /* Jayapura Time (Indonesia) */
|
{"jayt", TZ, POS(36)}, /* Jayapura Time (Indonesia) */
|
||||||
{"jd", UNITS, DTK_JULIAN},
|
{"jd", UNITS, DTK_JULIAN},
|
||||||
{"jst", TZ, 54}, /* Japan Std Time,USSR Zone 8 */
|
{"jst", TZ, POS(36)}, /* Japan Std Time,USSR Zone 8 */
|
||||||
{"jt", TZ, 45}, /* Java Time (07:30? see JAVT) */
|
{"jt", TZ, POS(30)}, /* Java Time (07:30? see JAVT) */
|
||||||
{"jul", MONTH, 7},
|
{"jul", MONTH, 7},
|
||||||
{"julian", UNITS, DTK_JULIAN},
|
{"julian", UNITS, DTK_JULIAN},
|
||||||
{"july", MONTH, 7},
|
{"july", MONTH, 7},
|
||||||
{"jun", MONTH, 6},
|
{"jun", MONTH, 6},
|
||||||
{"june", MONTH, 6},
|
{"june", MONTH, 6},
|
||||||
{"kdt", DTZ, 60}, /* Korea Daylight Time */
|
{"kdt", DTZ, POS(40)}, /* Korea Daylight Time */
|
||||||
{"kgst", DTZ, 36}, /* Kyrgyzstan Summer Time */
|
{"kgst", DTZ, POS(24)}, /* Kyrgyzstan Summer Time */
|
||||||
{"kgt", TZ, 30}, /* Kyrgyzstan Time */
|
{"kgt", TZ, POS(20)}, /* Kyrgyzstan Time */
|
||||||
{"kost", TZ, 72}, /* Kosrae Time */
|
{"kost", TZ, POS(48)}, /* Kosrae Time */
|
||||||
{"krast", DTZ, 42}, /* Krasnoyarsk Summer Time */
|
{"krast", DTZ, POS(28)}, /* Krasnoyarsk Summer Time */
|
||||||
{"krat", TZ, 48}, /* Krasnoyarsk Standard Time */
|
{"krat", TZ, POS(32)}, /* Krasnoyarsk Standard Time */
|
||||||
{"kst", TZ, 54}, /* Korea Standard Time */
|
{"kst", TZ, POS(36)}, /* Korea Standard Time */
|
||||||
{"lhdt", DTZ, 66}, /* Lord Howe Daylight Time, Australia */
|
{"lhdt", DTZ, POS(44)}, /* Lord Howe Daylight Time, Australia */
|
||||||
{"lhst", TZ, 63}, /* Lord Howe Standard Time, Australia */
|
{"lhst", TZ, POS(42)}, /* Lord Howe Standard Time, Australia */
|
||||||
{"ligt", TZ, 60}, /* From Melbourne, Australia */
|
{"ligt", TZ, POS(40)}, /* From Melbourne, Australia */
|
||||||
{"lint", TZ, 84}, /* Line Islands Time (Kiribati; +14 hours!) */
|
{"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14 hours!) */
|
||||||
{"lkt", TZ, 36}, /* Lanka Time */
|
{"lkt", TZ, POS(24)}, /* Lanka Time */
|
||||||
{"m", UNITS, DTK_MONTH}, /* "month" for ISO input */
|
{"m", UNITS, DTK_MONTH}, /* "month" for ISO input */
|
||||||
{"magst", DTZ, 72}, /* Magadan Summer Time */
|
{"magst", DTZ, POS(48)}, /* Magadan Summer Time */
|
||||||
{"magt", TZ, 66}, /* Magadan Time */
|
{"magt", TZ, POS(44)}, /* Magadan Time */
|
||||||
{"mar", MONTH, 3},
|
{"mar", MONTH, 3},
|
||||||
{"march", MONTH, 3},
|
{"march", MONTH, 3},
|
||||||
{"mart", TZ, NEG(57)}, /* Marquesas Time */
|
{"mart", TZ, NEG(38)}, /* Marquesas Time */
|
||||||
{"mawt", TZ, 36}, /* Mawson, Antarctica */
|
{"mawt", TZ, POS(24)}, /* Mawson, Antarctica */
|
||||||
{"may", MONTH, 5},
|
{"may", MONTH, 5},
|
||||||
{"mdt", DTZ, NEG(36)}, /* Mountain Daylight Time */
|
{"mdt", DTZ, NEG(24)}, /* Mountain Daylight Time */
|
||||||
{"mest", DTZ, 12}, /* Middle Europe Summer Time */
|
{"mest", DTZ, POS(8)}, /* Middle Europe Summer Time */
|
||||||
{"met", TZ, 6}, /* Middle Europe Time */
|
{"met", TZ, POS(4)}, /* Middle Europe Time */
|
||||||
{"metdst", DTZ, 12}, /* Middle Europe Daylight Time */
|
{"metdst", DTZ, POS(8)}, /* Middle Europe Daylight Time */
|
||||||
{"mewt", TZ, 6}, /* Middle Europe Winter Time */
|
{"mewt", TZ, POS(4)}, /* Middle Europe Winter Time */
|
||||||
{"mez", TZ, 6}, /* Middle Europe Zone */
|
{"mez", TZ, POS(4)}, /* Middle Europe Zone */
|
||||||
{"mht", TZ, 72}, /* Kwajalein */
|
{"mht", TZ, POS(48)}, /* Kwajalein */
|
||||||
{"mm", UNITS, DTK_MINUTE}, /* "minute" for ISO input */
|
{"mm", UNITS, DTK_MINUTE}, /* "minute" for ISO input */
|
||||||
{"mmt", TZ, 39}, /* Myannar Time */
|
{"mmt", TZ, POS(26)}, /* Myannar Time */
|
||||||
{"mon", DOW, 1},
|
{"mon", DOW, 1},
|
||||||
{"monday", DOW, 1},
|
{"monday", DOW, 1},
|
||||||
#if 0
|
#if 0
|
||||||
most
|
most
|
||||||
#endif
|
#endif
|
||||||
{"mpt", TZ, 60}, /* North Mariana Islands Time */
|
{"mpt", TZ, POS(40)}, /* North Mariana Islands Time */
|
||||||
{"msd", DTZ, 24}, /* Moscow Summer Time */
|
{"msd", DTZ, POS(16)}, /* Moscow Summer Time */
|
||||||
{"msk", TZ, 18}, /* Moscow Time */
|
{"msk", TZ, POS(12)}, /* Moscow Time */
|
||||||
{"mst", TZ, NEG(42)}, /* Mountain Standard Time */
|
{"mst", TZ, NEG(28)}, /* Mountain Standard Time */
|
||||||
{"mt", TZ, 51}, /* Moluccas Time */
|
{"mt", TZ, POS(34)}, /* Moluccas Time */
|
||||||
{"mut", TZ, 24}, /* Mauritius Island Time */
|
{"mut", TZ, POS(16)}, /* Mauritius Island Time */
|
||||||
{"mvt", TZ, 30}, /* Maldives Island Time */
|
{"mvt", TZ, POS(20)}, /* Maldives Island Time */
|
||||||
{"myt", TZ, 48}, /* Malaysia Time */
|
{"myt", TZ, POS(32)}, /* Malaysia Time */
|
||||||
#if 0
|
#if 0
|
||||||
ncst
|
ncst
|
||||||
#endif
|
#endif
|
||||||
{"nct", TZ, 66}, /* New Caledonia Time */
|
{"nct", TZ, POS(44)}, /* New Caledonia Time */
|
||||||
{"ndt", DTZ, NEG(15)}, /* Nfld. Daylight Time */
|
{"ndt", DTZ, NEG(10)}, /* Nfld. Daylight Time */
|
||||||
{"nft", TZ, NEG(21)}, /* Newfoundland Standard Time */
|
{"nft", TZ, NEG(14)}, /* Newfoundland Standard Time */
|
||||||
{"nor", TZ, 6}, /* Norway Standard Time */
|
{"nor", TZ, POS(4)}, /* Norway Standard Time */
|
||||||
{"nov", MONTH, 11},
|
{"nov", MONTH, 11},
|
||||||
{"november", MONTH, 11},
|
{"november", MONTH, 11},
|
||||||
{"novst", DTZ, 42}, /* Novosibirsk Summer Time */
|
{"novst", DTZ, POS(28)}, /* Novosibirsk Summer Time */
|
||||||
{"novt", TZ, 36}, /* Novosibirsk Standard Time */
|
{"novt", TZ, POS(24)}, /* Novosibirsk Standard Time */
|
||||||
{NOW, RESERV, DTK_NOW}, /* current transaction time */
|
{NOW, RESERV, DTK_NOW}, /* current transaction time */
|
||||||
{"nst", TZ, NEG(21)}, /* Nfld. Standard Time */
|
{"npt", TZ, POS(23)}, /* Nepal Standard Time (GMT-5:45) */
|
||||||
{"nt", TZ, NEG(66)}, /* Nome Time */
|
{"nst", TZ, NEG(14)}, /* Nfld. Standard Time */
|
||||||
{"nut", TZ, NEG(66)}, /* Niue Time */
|
{"nt", TZ, NEG(44)}, /* Nome Time */
|
||||||
{"nzdt", DTZ, 78}, /* New Zealand Daylight Time */
|
{"nut", TZ, NEG(44)}, /* Niue Time */
|
||||||
{"nzst", TZ, 72}, /* New Zealand Standard Time */
|
{"nzdt", DTZ, POS(52)}, /* New Zealand Daylight Time */
|
||||||
{"nzt", TZ, 72}, /* New Zealand Time */
|
{"nzst", TZ, POS(48)}, /* New Zealand Standard Time */
|
||||||
|
{"nzt", TZ, POS(48)}, /* New Zealand Time */
|
||||||
{"oct", MONTH, 10},
|
{"oct", MONTH, 10},
|
||||||
{"october", MONTH, 10},
|
{"october", MONTH, 10},
|
||||||
{"omsst", DTZ, 42}, /* Omsk Summer Time */
|
{"omsst", DTZ, POS(28)}, /* Omsk Summer Time */
|
||||||
{"omst", TZ, 36}, /* Omsk Time */
|
{"omst", TZ, POS(24)}, /* Omsk Time */
|
||||||
{"on", IGNORE_DTF, 0}, /* "on" (throwaway) */
|
{"on", IGNORE_DTF, 0}, /* "on" (throwaway) */
|
||||||
{"pdt", DTZ, NEG(42)}, /* Pacific Daylight Time */
|
{"pdt", DTZ, NEG(28)}, /* Pacific Daylight Time */
|
||||||
#if 0
|
#if 0
|
||||||
pest
|
pest
|
||||||
#endif
|
#endif
|
||||||
{"pet", TZ, NEG(30)}, /* Peru Time */
|
{"pet", TZ, NEG(20)}, /* Peru Time */
|
||||||
{"petst", DTZ, 78}, /* Petropavlovsk-Kamchatski Summer Time */
|
{"petst", DTZ, POS(52)}, /* Petropavlovsk-Kamchatski Summer Time */
|
||||||
{"pett", TZ, 72}, /* Petropavlovsk-Kamchatski Time */
|
{"pett", TZ, POS(48)}, /* Petropavlovsk-Kamchatski Time */
|
||||||
{"pgt", TZ, 60}, /* Papua New Guinea Time */
|
{"pgt", TZ, POS(40)}, /* Papua New Guinea Time */
|
||||||
{"phot", TZ, 78}, /* Phoenix Islands (Kiribati) Time */
|
{"phot", TZ, POS(52)}, /* Phoenix Islands (Kiribati) Time */
|
||||||
#if 0
|
#if 0
|
||||||
phst
|
phst
|
||||||
#endif
|
#endif
|
||||||
{"pht", TZ, 48}, /* Phillipine Time */
|
{"pht", TZ, POS(32)}, /* Phillipine Time */
|
||||||
{"pkt", TZ, 30}, /* Pakistan Time */
|
{"pkt", TZ, POS(20)}, /* Pakistan Time */
|
||||||
{"pm", AMPM, PM},
|
{"pm", AMPM, PM},
|
||||||
{"pmdt", DTZ, NEG(12)}, /* Pierre & Miquelon Daylight Time */
|
{"pmdt", DTZ, NEG(8)}, /* Pierre & Miquelon Daylight Time */
|
||||||
#if 0
|
#if 0
|
||||||
pmst
|
pmst
|
||||||
#endif
|
#endif
|
||||||
{"pont", TZ, 66}, /* Ponape Time (Micronesia) */
|
{"pont", TZ, POS(44)}, /* Ponape Time (Micronesia) */
|
||||||
{"pst", TZ, NEG(48)}, /* Pacific Standard Time */
|
{"pst", TZ, NEG(32)}, /* Pacific Standard Time */
|
||||||
{"pwt", TZ, 54}, /* Palau Time */
|
{"pwt", TZ, POS(36)}, /* Palau Time */
|
||||||
{"pyst", DTZ, NEG(18)}, /* Paraguay Summer Time */
|
{"pyst", DTZ, NEG(12)}, /* Paraguay Summer Time */
|
||||||
{"pyt", TZ, NEG(24)}, /* Paraguay Time */
|
{"pyt", TZ, NEG(16)}, /* Paraguay Time */
|
||||||
{"ret", DTZ, 24}, /* Reunion Island Time */
|
{"ret", DTZ, POS(16)}, /* Reunion Island Time */
|
||||||
{"s", UNITS, DTK_SECOND}, /* "seconds" for ISO input */
|
{"s", UNITS, DTK_SECOND}, /* "seconds" for ISO input */
|
||||||
{"sadt", DTZ, 63}, /* S. Australian Dayl. Time */
|
{"sadt", DTZ, POS(42)}, /* S. Australian Dayl. Time */
|
||||||
#if 0
|
#if 0
|
||||||
samst
|
samst
|
||||||
samt
|
samt
|
||||||
#endif
|
#endif
|
||||||
{"sast", TZ, 57}, /* South Australian Std Time */
|
{"sast", TZ, POS(38)}, /* South Australian Std Time */
|
||||||
{"sat", DOW, 6},
|
{"sat", DOW, 6},
|
||||||
{"saturday", DOW, 6},
|
{"saturday", DOW, 6},
|
||||||
#if 0
|
#if 0
|
||||||
sbt
|
sbt
|
||||||
#endif
|
#endif
|
||||||
{"sct", DTZ, 24}, /* Mahe Island Time */
|
{"sct", DTZ, POS(16)}, /* Mahe Island Time */
|
||||||
{"sep", MONTH, 9},
|
{"sep", MONTH, 9},
|
||||||
{"sept", MONTH, 9},
|
{"sept", MONTH, 9},
|
||||||
{"september", MONTH, 9},
|
{"september", MONTH, 9},
|
||||||
{"set", TZ, NEG(6)}, /* Seychelles Time ?? */
|
{"set", TZ, NEG(4)}, /* Seychelles Time ?? */
|
||||||
#if 0
|
#if 0
|
||||||
sgt
|
sgt
|
||||||
#endif
|
#endif
|
||||||
{"sst", DTZ, 12}, /* Swedish Summer Time */
|
{"sst", DTZ, POS(8)}, /* Swedish Summer Time */
|
||||||
{"sun", DOW, 0},
|
{"sun", DOW, 0},
|
||||||
{"sunday", DOW, 0},
|
{"sunday", DOW, 0},
|
||||||
{"swt", TZ, 6}, /* Swedish Winter Time */
|
{"swt", TZ, POS(4)}, /* Swedish Winter Time */
|
||||||
#if 0
|
#if 0
|
||||||
syot
|
syot
|
||||||
#endif
|
#endif
|
||||||
{"t", ISOTIME, DTK_TIME}, /* Filler for ISO time fields */
|
{"t", ISOTIME, DTK_TIME}, /* Filler for ISO time fields */
|
||||||
{"that", TZ, NEG(60)}, /* Tahiti Time */
|
{"that", TZ, NEG(40)}, /* Tahiti Time */
|
||||||
{"tft", TZ, 30}, /* Kerguelen Time */
|
{"tft", TZ, POS(20)}, /* Kerguelen Time */
|
||||||
{"thu", DOW, 4},
|
{"thu", DOW, 4},
|
||||||
{"thur", DOW, 4},
|
{"thur", DOW, 4},
|
||||||
{"thurs", DOW, 4},
|
{"thurs", DOW, 4},
|
||||||
{"thursday", DOW, 4},
|
{"thursday", DOW, 4},
|
||||||
{"tjt", TZ, 30}, /* Tajikistan Time */
|
{"tjt", TZ, POS(20)}, /* Tajikistan Time */
|
||||||
{"tkt", TZ, NEG(60)}, /* Tokelau Time */
|
{"tkt", TZ, NEG(40)}, /* Tokelau Time */
|
||||||
{"tmt", TZ, 30}, /* Turkmenistan Time */
|
{"tmt", TZ, POS(20)}, /* Turkmenistan Time */
|
||||||
{TODAY, RESERV, DTK_TODAY}, /* midnight */
|
{TODAY, RESERV, DTK_TODAY}, /* midnight */
|
||||||
{TOMORROW, RESERV, DTK_TOMORROW}, /* tomorrow midnight */
|
{TOMORROW, RESERV, DTK_TOMORROW}, /* tomorrow midnight */
|
||||||
#if 0
|
#if 0
|
||||||
tost
|
tost
|
||||||
#endif
|
#endif
|
||||||
{"tot", TZ, 78}, /* Tonga Time */
|
{"tot", TZ, POS(52)}, /* Tonga Time */
|
||||||
#if 0
|
#if 0
|
||||||
tpt
|
tpt
|
||||||
#endif
|
#endif
|
||||||
{"truk", TZ, 60}, /* Truk Time */
|
{"truk", TZ, POS(40)}, /* Truk Time */
|
||||||
{"tue", DOW, 2},
|
{"tue", DOW, 2},
|
||||||
{"tues", DOW, 2},
|
{"tues", DOW, 2},
|
||||||
{"tuesday", DOW, 2},
|
{"tuesday", DOW, 2},
|
||||||
{"tvt", TZ, 72}, /* Tuvalu Time */
|
{"tvt", TZ, POS(48)}, /* Tuvalu Time */
|
||||||
#if 0
|
#if 0
|
||||||
uct
|
uct
|
||||||
#endif
|
#endif
|
||||||
{"ulast", DTZ, 54}, /* Ulan Bator Summer Time */
|
{"ulast", DTZ, POS(36)}, /* Ulan Bator Summer Time */
|
||||||
{"ulat", TZ, 48}, /* Ulan Bator Time */
|
{"ulat", TZ, POS(32)}, /* Ulan Bator Time */
|
||||||
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
|
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
|
||||||
{"ut", TZ, 0},
|
{"ut", TZ, POS(0)},
|
||||||
{"utc", TZ, 0},
|
{"utc", TZ, POS(0)},
|
||||||
{"uyst", DTZ, NEG(12)}, /* Uruguay Summer Time */
|
{"uyst", DTZ, NEG(8)}, /* Uruguay Summer Time */
|
||||||
{"uyt", TZ, NEG(18)}, /* Uruguay Time */
|
{"uyt", TZ, NEG(12)}, /* Uruguay Time */
|
||||||
{"uzst", DTZ, 36}, /* Uzbekistan Summer Time */
|
{"uzst", DTZ, POS(24)}, /* Uzbekistan Summer Time */
|
||||||
{"uzt", TZ, 30}, /* Uzbekistan Time */
|
{"uzt", TZ, POS(20)}, /* Uzbekistan Time */
|
||||||
{"vet", TZ, NEG(24)}, /* Venezuela Time */
|
{"vet", TZ, NEG(16)}, /* Venezuela Time */
|
||||||
{"vlast", DTZ, 66}, /* Vladivostok Summer Time */
|
{"vlast", DTZ, POS(44)}, /* Vladivostok Summer Time */
|
||||||
{"vlat", TZ, 60}, /* Vladivostok Time */
|
{"vlat", TZ, POS(40)}, /* Vladivostok Time */
|
||||||
#if 0
|
#if 0
|
||||||
vust
|
vust
|
||||||
#endif
|
#endif
|
||||||
{"vut", TZ, 66}, /* Vanuata Time */
|
{"vut", TZ, POS(44)}, /* Vanuata Time */
|
||||||
{"wadt", DTZ, 48}, /* West Australian DST */
|
{"wadt", DTZ, POS(32)}, /* West Australian DST */
|
||||||
{"wakt", TZ, 72}, /* Wake Time */
|
{"wakt", TZ, POS(48)}, /* Wake Time */
|
||||||
#if 0
|
#if 0
|
||||||
warst
|
warst
|
||||||
#endif
|
#endif
|
||||||
{"wast", TZ, 42}, /* West Australian Std Time */
|
{"wast", TZ, POS(28)}, /* West Australian Std Time */
|
||||||
{"wat", TZ, NEG(6)}, /* West Africa Time */
|
{"wat", TZ, NEG(4)}, /* West Africa Time */
|
||||||
{"wdt", DTZ, 54}, /* West Australian DST */
|
{"wdt", DTZ, POS(36)}, /* West Australian DST */
|
||||||
{"wed", DOW, 3},
|
{"wed", DOW, 3},
|
||||||
{"wednesday", DOW, 3},
|
{"wednesday", DOW, 3},
|
||||||
{"weds", DOW, 3},
|
{"weds", DOW, 3},
|
||||||
{"west", DTZ, 6}, /* Western Europe Summer Time */
|
{"west", DTZ, POS(4)}, /* Western Europe Summer Time */
|
||||||
{"wet", TZ, 0}, /* Western Europe */
|
{"wet", TZ, POS(0)}, /* Western Europe */
|
||||||
{"wetdst", DTZ, 6}, /* Western Europe Daylight Savings Time */
|
{"wetdst", DTZ, POS(4)}, /* Western Europe Daylight Savings Time */
|
||||||
{"wft", TZ, 72}, /* Wallis and Futuna Time */
|
{"wft", TZ, POS(48)}, /* Wallis and Futuna Time */
|
||||||
{"wgst", DTZ, NEG(12)}, /* West Greenland Summer Time */
|
{"wgst", DTZ, NEG(8)}, /* West Greenland Summer Time */
|
||||||
{"wgt", TZ, NEG(18)}, /* West Greenland Time */
|
{"wgt", TZ, NEG(12)}, /* West Greenland Time */
|
||||||
{"wst", TZ, 48}, /* West Australian Standard Time */
|
{"wst", TZ, POS(32)}, /* West Australian Standard Time */
|
||||||
{"y", UNITS, DTK_YEAR}, /* "year" for ISO input */
|
{"y", UNITS, DTK_YEAR}, /* "year" for ISO input */
|
||||||
{"yakst", DTZ, 60}, /* Yakutsk Summer Time */
|
{"yakst", DTZ, POS(40)}, /* Yakutsk Summer Time */
|
||||||
{"yakt", TZ, 54}, /* Yakutsk Time */
|
{"yakt", TZ, POS(36)}, /* Yakutsk Time */
|
||||||
{"yapt", TZ, 60}, /* Yap Time (Micronesia) */
|
{"yapt", TZ, POS(40)}, /* Yap Time (Micronesia) */
|
||||||
{"ydt", DTZ, NEG(48)}, /* Yukon Daylight Time */
|
{"ydt", DTZ, NEG(32)}, /* Yukon Daylight Time */
|
||||||
{"yekst", DTZ, 36}, /* Yekaterinburg Summer Time */
|
{"yekst", DTZ, POS(24)}, /* Yekaterinburg Summer Time */
|
||||||
{"yekt", TZ, 30}, /* Yekaterinburg Time */
|
{"yekt", TZ, POS(20)}, /* Yekaterinburg Time */
|
||||||
{YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */
|
{YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */
|
||||||
{"yst", TZ, NEG(54)}, /* Yukon Standard Time */
|
{"yst", TZ, NEG(36)}, /* Yukon Standard Time */
|
||||||
{"z", TZ, 0}, /* time zone tag per ISO-8601 */
|
{"z", TZ, POS(0)}, /* time zone tag per ISO-8601 */
|
||||||
{"zp4", TZ, NEG(24)}, /* UTC +4 hours. */
|
{"zp4", TZ, NEG(16)}, /* UTC +4 hours. */
|
||||||
{"zp5", TZ, NEG(30)}, /* UTC +5 hours. */
|
{"zp5", TZ, NEG(20)}, /* UTC +5 hours. */
|
||||||
{"zp6", TZ, NEG(36)}, /* UTC +6 hours. */
|
{"zp6", TZ, NEG(24)}, /* UTC +6 hours. */
|
||||||
{ZULU, TZ, 0}, /* UTC */
|
{ZULU, TZ, POS(0)}, /* UTC */
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
|
static unsigned int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
|
||||||
|
|
||||||
/* Used for SET australian_timezones to override North American ones */
|
/* Used for SET australian_timezones to override North American ones */
|
||||||
static datetkn australian_datetktbl[] = {
|
static datetkn australian_datetktbl[] = {
|
||||||
{"acst", TZ, 57}, /* Cent. Australia */
|
{"acst", TZ, POS(38)}, /* Cent. Australia */
|
||||||
{"cst", TZ, 63}, /* Australia Central Std Time */
|
{"cst", TZ, POS(42)}, /* Australia Central Std Time */
|
||||||
{"east", TZ, 60}, /* East Australian Std Time */
|
{"east", TZ, POS(40)}, /* East Australian Std Time */
|
||||||
{"est", TZ, 60}, /* Australia Eastern Std Time */
|
{"est", TZ, POS(40)}, /* Australia Eastern Std Time */
|
||||||
{"sat", TZ, 57},
|
{"sat", TZ, POS(38)},
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int australian_szdatetktbl = sizeof australian_datetktbl /
|
static unsigned int australian_szdatetktbl = sizeof australian_datetktbl /
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.30 2002/06/20 20:29:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.31 2002/08/04 06:44:47 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -29,9 +29,6 @@
|
|||||||
#include "mb/pg_wchar.h"
|
#include "mb/pg_wchar.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define MASK(b) (1 << (b))
|
|
||||||
|
|
||||||
#define MAX_INT32_LEN 11
|
#define MAX_INT32_LEN 11
|
||||||
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
|
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
|
||||||
|
|
||||||
@ -258,52 +255,63 @@ format_type_internal(Oid type_oid, int32 typemod,
|
|||||||
case INTERVALOID:
|
case INTERVALOID:
|
||||||
if (with_typemod)
|
if (with_typemod)
|
||||||
{
|
{
|
||||||
int fields = typemod >> 16;
|
int fields = INTERVAL_RANGE(typemod);
|
||||||
int precision = typemod & 0xFFFF;
|
int precision = INTERVAL_PRECISION(typemod);
|
||||||
const char *fieldstr;
|
const char *fieldstr;
|
||||||
|
|
||||||
switch (fields)
|
switch (fields)
|
||||||
{
|
{
|
||||||
case MASK(YEAR):
|
case INTERVAL_MASK(YEAR):
|
||||||
fieldstr = " year";
|
fieldstr = " year";
|
||||||
break;
|
break;
|
||||||
case MASK(MONTH):
|
case INTERVAL_MASK(MONTH):
|
||||||
fieldstr = " month";
|
fieldstr = " month";
|
||||||
break;
|
break;
|
||||||
case MASK(DAY):
|
case INTERVAL_MASK(DAY):
|
||||||
fieldstr = " day";
|
fieldstr = " day";
|
||||||
break;
|
break;
|
||||||
case MASK(HOUR):
|
case INTERVAL_MASK(HOUR):
|
||||||
fieldstr = " hour";
|
fieldstr = " hour";
|
||||||
break;
|
break;
|
||||||
case MASK(MINUTE):
|
case INTERVAL_MASK(MINUTE):
|
||||||
fieldstr = " minute";
|
fieldstr = " minute";
|
||||||
break;
|
break;
|
||||||
case MASK(SECOND):
|
case INTERVAL_MASK(SECOND):
|
||||||
fieldstr = " second";
|
fieldstr = " second";
|
||||||
break;
|
break;
|
||||||
case MASK(YEAR) | MASK(MONTH):
|
case INTERVAL_MASK(YEAR)
|
||||||
|
| INTERVAL_MASK(MONTH):
|
||||||
fieldstr = " year to month";
|
fieldstr = " year to month";
|
||||||
break;
|
break;
|
||||||
case MASK(DAY) | MASK(HOUR):
|
case INTERVAL_MASK(DAY)
|
||||||
|
| INTERVAL_MASK(HOUR):
|
||||||
fieldstr = " day to hour";
|
fieldstr = " day to hour";
|
||||||
break;
|
break;
|
||||||
case MASK(DAY) | MASK(HOUR) | MASK(MINUTE):
|
case INTERVAL_MASK(DAY)
|
||||||
|
| INTERVAL_MASK(HOUR)
|
||||||
|
| INTERVAL_MASK(MINUTE):
|
||||||
fieldstr = " day to minute";
|
fieldstr = " day to minute";
|
||||||
break;
|
break;
|
||||||
case MASK(DAY) | MASK(HOUR) | MASK(MINUTE) | MASK(SECOND):
|
case INTERVAL_MASK(DAY)
|
||||||
|
| INTERVAL_MASK(HOUR)
|
||||||
|
| INTERVAL_MASK(MINUTE)
|
||||||
|
| INTERVAL_MASK(SECOND):
|
||||||
fieldstr = " day to second";
|
fieldstr = " day to second";
|
||||||
break;
|
break;
|
||||||
case MASK(HOUR) | MASK(MINUTE):
|
case INTERVAL_MASK(HOUR)
|
||||||
|
| INTERVAL_MASK(MINUTE):
|
||||||
fieldstr = " hour to minute";
|
fieldstr = " hour to minute";
|
||||||
break;
|
break;
|
||||||
case MASK(HOUR) | MASK(MINUTE) | MASK(SECOND):
|
case INTERVAL_MASK(HOUR)
|
||||||
|
| INTERVAL_MASK(MINUTE)
|
||||||
|
| INTERVAL_MASK(SECOND):
|
||||||
fieldstr = " hour to second";
|
fieldstr = " hour to second";
|
||||||
break;
|
break;
|
||||||
case MASK(MINUTE) | MASK(SECOND):
|
case INTERVAL_MASK(MINUTE)
|
||||||
|
| INTERVAL_MASK(SECOND):
|
||||||
fieldstr = " minute to second";
|
fieldstr = " minute to second";
|
||||||
break;
|
break;
|
||||||
case 0x7FFF:
|
case INTERVAL_FULL_RANGE:
|
||||||
fieldstr = "";
|
fieldstr = "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -311,7 +319,7 @@ format_type_internal(Oid type_oid, int32 typemod,
|
|||||||
fieldstr = "";
|
fieldstr = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (precision != 0xFFFF)
|
if (precision != INTERVAL_FULL_PRECISION)
|
||||||
buf = psnprintf(100, "interval(%d)%s",
|
buf = psnprintf(100, "interval(%d)%s",
|
||||||
precision, fieldstr);
|
precision, fieldstr);
|
||||||
else
|
else
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.95 2002/06/20 20:29:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.96 2002/08/04 06:44:47 thomas Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -486,8 +486,8 @@ nabstimein(PG_FUNCTION_ARGS)
|
|||||||
int nf,
|
int nf,
|
||||||
ftype[MAXDATEFIELDS];
|
ftype[MAXDATEFIELDS];
|
||||||
|
|
||||||
if (strlen(str) > MAXDATELEN)
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
elog(ERROR, "Bad (length) abstime external representation '%s'", str);
|
elog(ERROR, "Bad abstime external representation (too long) '%s'", str);
|
||||||
|
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
||||||
@ -849,8 +849,8 @@ reltimein(PG_FUNCTION_ARGS)
|
|||||||
ftype[MAXDATEFIELDS];
|
ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + 1];
|
||||||
|
|
||||||
if (strlen(str) > MAXDATELEN)
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
elog(ERROR, "Bad (length) reltime external representation '%s'", str);
|
elog(ERROR, "Bad reltime external representation (too long) '%s'", str);
|
||||||
|
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||||
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0))
|
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0))
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.68 2002/06/20 20:29:38 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.69 2002/08/04 06:44:47 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -65,7 +65,10 @@ timestamp_in(PG_FUNCTION_ARGS)
|
|||||||
int nf;
|
int nf;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
||||||
|
|
||||||
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
|
elog(ERROR, "Bad timestamp external representation (too long) '%s'", str);
|
||||||
|
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
||||||
@ -251,7 +254,11 @@ timestamptz_in(PG_FUNCTION_ARGS)
|
|||||||
int nf;
|
int nf;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
||||||
|
|
||||||
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
|
elog(ERROR, "Bad timestamp with time zone"
|
||||||
|
" external representation (too long) '%s'", str);
|
||||||
|
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||||
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|
||||||
@ -359,7 +366,7 @@ interval_in(PG_FUNCTION_ARGS)
|
|||||||
int nf;
|
int nf;
|
||||||
char *field[MAXDATEFIELDS];
|
char *field[MAXDATEFIELDS];
|
||||||
int ftype[MAXDATEFIELDS];
|
int ftype[MAXDATEFIELDS];
|
||||||
char lowstr[MAXDATELEN + 1];
|
char lowstr[MAXDATELEN + MAXDATEFIELDS];
|
||||||
|
|
||||||
tm->tm_year = 0;
|
tm->tm_year = 0;
|
||||||
tm->tm_mon = 0;
|
tm->tm_mon = 0;
|
||||||
@ -369,6 +376,9 @@ interval_in(PG_FUNCTION_ARGS)
|
|||||||
tm->tm_sec = 0;
|
tm->tm_sec = 0;
|
||||||
fsec = 0;
|
fsec = 0;
|
||||||
|
|
||||||
|
if (strlen(str) >= sizeof(lowstr))
|
||||||
|
elog(ERROR, "Bad interval external representation (too long) '%s'", str);
|
||||||
|
|
||||||
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|
||||||
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0))
|
|| (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0))
|
||||||
elog(ERROR, "Bad interval external representation '%s'", str);
|
elog(ERROR, "Bad interval external representation '%s'", str);
|
||||||
@ -436,8 +446,6 @@ interval_scale(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_INTERVAL_P(result);
|
PG_RETURN_INTERVAL_P(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MASK(b) (1 << (b))
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||||
{
|
{
|
||||||
@ -483,31 +491,34 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Unspecified range and precision? Then not necessary to adjust.
|
||||||
|
* Setting typmod to -1 is the convention for all types.
|
||||||
|
*/
|
||||||
if (typmod != -1)
|
if (typmod != -1)
|
||||||
{
|
{
|
||||||
int range = ((typmod >> 16) & 0x7FFF);
|
int range = INTERVAL_RANGE(typmod);
|
||||||
int precision = (typmod & 0xFFFF);
|
int precision = INTERVAL_PRECISION(typmod);
|
||||||
|
|
||||||
if (range == 0x7FFF)
|
if (range == INTERVAL_FULL_RANGE)
|
||||||
{
|
{
|
||||||
/* Do nothing... */
|
/* Do nothing... */
|
||||||
}
|
}
|
||||||
else if (range == MASK(YEAR))
|
else if (range == INTERVAL_MASK(YEAR))
|
||||||
{
|
{
|
||||||
interval->month = ((interval->month / 12) * 12);
|
interval->month = ((interval->month / 12) * 12);
|
||||||
interval->time = 0;
|
interval->time = 0;
|
||||||
}
|
}
|
||||||
else if (range == MASK(MONTH))
|
else if (range == INTERVAL_MASK(MONTH))
|
||||||
{
|
{
|
||||||
interval->month %= 12;
|
interval->month %= 12;
|
||||||
interval->time = 0;
|
interval->time = 0;
|
||||||
}
|
}
|
||||||
/* YEAR TO MONTH */
|
/* YEAR TO MONTH */
|
||||||
else if (range == (MASK(YEAR) | MASK(MONTH)))
|
else if (range == (INTERVAL_MASK(YEAR) | INTERVAL_MASK(MONTH)))
|
||||||
{
|
{
|
||||||
interval->time = 0;
|
interval->time = 0;
|
||||||
}
|
}
|
||||||
else if (range == MASK(DAY))
|
else if (range == INTERVAL_MASK(DAY))
|
||||||
{
|
{
|
||||||
interval->month = 0;
|
interval->month = 0;
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
@ -517,7 +528,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
interval->time = (((int) (interval->time / 86400)) * 86400);
|
interval->time = (((int) (interval->time / 86400)) * 86400);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (range == MASK(HOUR))
|
else if (range == INTERVAL_MASK(HOUR))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 day;
|
int64 day;
|
||||||
@ -536,7 +547,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
interval->time = (((int) (interval->time / 3600)) * 3600.0);
|
interval->time = (((int) (interval->time / 3600)) * 3600.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (range == MASK(MINUTE))
|
else if (range == INTERVAL_MASK(MINUTE))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 hour;
|
int64 hour;
|
||||||
@ -555,7 +566,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
interval->time = (((int) (interval->time / 60)) * 60);
|
interval->time = (((int) (interval->time / 60)) * 60);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (range == MASK(SECOND))
|
else if (range == INTERVAL_MASK(SECOND))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 minute;
|
int64 minute;
|
||||||
@ -573,7 +584,8 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* DAY TO HOUR */
|
/* DAY TO HOUR */
|
||||||
else if (range == (MASK(DAY) | MASK(HOUR)))
|
else if (range == (INTERVAL_MASK(DAY) |
|
||||||
|
INTERVAL_MASK(HOUR)))
|
||||||
{
|
{
|
||||||
interval->month = 0;
|
interval->month = 0;
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
@ -584,7 +596,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* DAY TO MINUTE */
|
/* DAY TO MINUTE */
|
||||||
else if (range == (MASK(DAY) | MASK(HOUR) | MASK(MINUTE)))
|
else if (range == (INTERVAL_MASK(DAY) |
|
||||||
|
INTERVAL_MASK(HOUR) |
|
||||||
|
INTERVAL_MASK(MINUTE)))
|
||||||
{
|
{
|
||||||
interval->month = 0;
|
interval->month = 0;
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
@ -595,12 +609,16 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* DAY TO SECOND */
|
/* DAY TO SECOND */
|
||||||
else if (range == (MASK(DAY) | MASK(HOUR) | MASK(MINUTE) | MASK(SECOND)))
|
else if (range == (INTERVAL_MASK(DAY) |
|
||||||
|
INTERVAL_MASK(HOUR) |
|
||||||
|
INTERVAL_MASK(MINUTE) |
|
||||||
|
INTERVAL_MASK(SECOND)))
|
||||||
{
|
{
|
||||||
interval->month = 0;
|
interval->month = 0;
|
||||||
}
|
}
|
||||||
/* HOUR TO MINUTE */
|
/* HOUR TO MINUTE */
|
||||||
else if (range == (MASK(HOUR) | MASK(MINUTE)))
|
else if (range == (INTERVAL_MASK(HOUR) |
|
||||||
|
INTERVAL_MASK(MINUTE)))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 day;
|
int64 day;
|
||||||
@ -620,7 +638,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* HOUR TO SECOND */
|
/* HOUR TO SECOND */
|
||||||
else if (range == (MASK(HOUR) | MASK(MINUTE) | MASK(SECOND)))
|
else if (range == (INTERVAL_MASK(HOUR) |
|
||||||
|
INTERVAL_MASK(MINUTE) |
|
||||||
|
INTERVAL_MASK(SECOND)))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 day;
|
int64 day;
|
||||||
@ -637,7 +657,8 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* MINUTE TO SECOND */
|
/* MINUTE TO SECOND */
|
||||||
else if (range == (MASK(MINUTE) | MASK(SECOND)))
|
else if (range == (INTERVAL_MASK(MINUTE) |
|
||||||
|
INTERVAL_MASK(SECOND)))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 hour;
|
int64 hour;
|
||||||
@ -657,7 +678,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
|||||||
elog(ERROR, "AdjustIntervalForTypmod(): internal coding error");
|
elog(ERROR, "AdjustIntervalForTypmod(): internal coding error");
|
||||||
|
|
||||||
/* Need to adjust precision? If not, don't even try! */
|
/* Need to adjust precision? If not, don't even try! */
|
||||||
if (precision != 0xFFFF)
|
if (precision != INTERVAL_FULL_PRECISION)
|
||||||
{
|
{
|
||||||
if ((precision < 0) || (precision > MAX_INTERVAL_PRECISION))
|
if ((precision < 0) || (precision > MAX_INTERVAL_PRECISION))
|
||||||
elog(ERROR, "INTERVAL(%d) precision must be between %d and %d",
|
elog(ERROR, "INTERVAL(%d) precision must be between %d and %d",
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.86 2002/06/20 20:29:38 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.87 2002/08/04 06:44:47 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -550,7 +550,7 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
|
|||||||
/*
|
/*
|
||||||
* Unfortunately, there is no strncoll(), so in the non-C locale
|
* Unfortunately, there is no strncoll(), so in the non-C locale
|
||||||
* case we have to do some memory copying. This turns out to be
|
* case we have to do some memory copying. This turns out to be
|
||||||
* significantly slower, so we optimize the case were LC_COLLATE
|
* significantly slower, so we optimize the case where LC_COLLATE
|
||||||
* is C.
|
* is C.
|
||||||
*/
|
*/
|
||||||
if (!lc_collate_is_c())
|
if (!lc_collate_is_c())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user