|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.62 1999/01/20 16:29:39 thomas Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.63 1999/02/13 04:25:01 thomas Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -249,7 +249,7 @@ timespan_in(char *str)
|
249 | 249 | caseDTK_DELTA:
|
250 | 250 | if (tm2timespan(tm,fsec,span)!=0)
|
251 | 251 | {
|
252 |
| -#ifFALSE |
| 252 | +#ifNOT_USED |
253 | 253 | TIMESPAN_INVALID(span);
|
254 | 254 | #endif
|
255 | 255 | elog(ERROR,"Bad timespan external representation '%s'",str);
|
@@ -1412,7 +1412,7 @@ datetime_trunc(text *units, DateTime *datetime)
|
1412 | 1412 |
|
1413 | 1413 | if (DATETIME_NOT_FINITE(*datetime))
|
1414 | 1414 | {
|
1415 |
| -#ifFALSE |
| 1415 | +#ifNOT_USED |
1416 | 1416 | /* should return null but Postgres doesn't like that currently. - tgl 97/06/12 */
|
1417 | 1417 | elog(ERROR,"Datetime is not finite",NULL);
|
1418 | 1418 | #endif
|
@@ -1494,7 +1494,7 @@ datetime_trunc(text *units, DateTime *datetime)
|
1494 | 1494 | if (tm2datetime(tm,fsec,&tz,result)!=0)
|
1495 | 1495 | elog(ERROR,"Unable to truncate datetime to '%s'",lowunits);
|
1496 | 1496 |
|
1497 |
| -#ifFALSE |
| 1497 | +#ifNOT_USED |
1498 | 1498 | }
|
1499 | 1499 | elseif ((type==RESERV)&& (val==DTK_EPOCH))
|
1500 | 1500 | {
|
@@ -1552,7 +1552,7 @@ timespan_trunc(text *units, TimeSpan *timespan)
|
1552 | 1552 |
|
1553 | 1553 | if (TIMESPAN_IS_INVALID(*timespan))
|
1554 | 1554 | {
|
1555 |
| -#ifFALSE |
| 1555 | +#ifNOT_USED |
1556 | 1556 | elog(ERROR,"Timespan is not finite",NULL);
|
1557 | 1557 | #endif
|
1558 | 1558 | result=NULL;
|
@@ -1610,7 +1610,7 @@ timespan_trunc(text *units, TimeSpan *timespan)
|
1610 | 1610 | result=NULL;
|
1611 | 1611 | }
|
1612 | 1612 |
|
1613 |
| -#ifFALSE |
| 1613 | +#ifNOT_USED |
1614 | 1614 | }
|
1615 | 1615 | elseif ((type==RESERV)&& (val==DTK_EPOCH))
|
1616 | 1616 | {
|
@@ -1678,7 +1678,7 @@ datetime_part(text *units, DateTime *datetime)
|
1678 | 1678 |
|
1679 | 1679 | if (DATETIME_NOT_FINITE(*datetime))
|
1680 | 1680 | {
|
1681 |
| -#ifFALSE |
| 1681 | +#ifNOT_USED |
1682 | 1682 | /* should return null but Postgres doesn't like that currently. - tgl 97/06/12 */
|
1683 | 1683 | elog(ERROR,"Datetime is not finite",NULL);
|
1684 | 1684 | #endif
|
@@ -1843,7 +1843,7 @@ timespan_part(text *units, TimeSpan *timespan)
|
1843 | 1843 |
|
1844 | 1844 | if (TIMESPAN_IS_INVALID(*timespan))
|
1845 | 1845 | {
|
1846 |
| -#ifFALSE |
| 1846 | +#ifNOT_USED |
1847 | 1847 | elog(ERROR,"Timespan is not finite",NULL);
|
1848 | 1848 | #endif
|
1849 | 1849 | *result=0;
|
@@ -1893,15 +1893,15 @@ timespan_part(text *units, TimeSpan *timespan)
|
1893 | 1893 | break;
|
1894 | 1894 |
|
1895 | 1895 | caseDTK_DECADE:
|
1896 |
| -*result= (tm->tm_year /10)+1; |
| 1896 | +*result= (tm->tm_year /10); |
1897 | 1897 | break;
|
1898 | 1898 |
|
1899 | 1899 | caseDTK_CENTURY:
|
1900 |
| -*result= (tm->tm_year /100)+1; |
| 1900 | +*result= (tm->tm_year /100); |
1901 | 1901 | break;
|
1902 | 1902 |
|
1903 | 1903 | caseDTK_MILLENIUM:
|
1904 |
| -*result= (tm->tm_year /1000)+1; |
| 1904 | +*result= (tm->tm_year /1000); |
1905 | 1905 | break;
|
1906 | 1906 |
|
1907 | 1907 | default:
|
@@ -2454,7 +2454,7 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
|
2454 | 2454 | tm->tm_mday=tx->tm_mday;
|
2455 | 2455 | tm->tm_hour=tx->tm_hour;
|
2456 | 2456 | tm->tm_min=tx->tm_min;
|
2457 |
| -#ifFALSE |
| 2457 | +#ifNOT_USED |
2458 | 2458 | /* XXX HACK
|
2459 | 2459 | * Argh! My Linux box puts in a 1 second offset for dates less than 1970
|
2460 | 2460 | *but only if the seconds field was non-zero. So, don't copy the seconds
|
@@ -2814,6 +2814,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
2814 | 2814 | intflen,
|
2815 | 2815 | val;
|
2816 | 2816 | intmer=HR24;
|
| 2817 | +inthaveTextMonth= FALSE; |
2817 | 2818 | intis2digits= FALSE;
|
2818 | 2819 | intbc= FALSE;
|
2819 | 2820 |
|
@@ -2955,14 +2956,23 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
2955 | 2956 | #ifdefDATEDEBUG
|
2956 | 2957 | printf("DecodeDateTime- month field %s value is %d\n",field[i],val);
|
2957 | 2958 | #endif
|
| 2959 | +/* already have a (numeric) month? then see if we can substitute... */ |
| 2960 | +if ((fmask&DTK_M(MONTH))&& (!haveTextMonth) |
| 2961 | +&& (!(fmask&DTK_M(DAY))) |
| 2962 | +&& ((tm->tm_mon >=1)&& (tm->tm_mon <=31))) |
| 2963 | +{ |
| 2964 | +tm->tm_mday=tm->tm_mon; |
| 2965 | +tmask=DTK_M(DAY); |
| 2966 | +#ifdefDATEDEBUG |
| 2967 | +printf("DecodeNumber- misidentified month previously; assign as day %d\n",tm->tm_mday); |
| 2968 | +#endif |
| 2969 | +} |
| 2970 | +haveTextMonth= TRUE; |
2958 | 2971 | tm->tm_mon=val;
|
2959 | 2972 | break;
|
2960 | 2973 |
|
2961 |
| -/* |
2962 |
| - * daylight savings time modifier (solves "MET |
2963 |
| - * DST" syntax) |
2964 |
| - */ |
2965 | 2974 | caseDTZMOD:
|
| 2975 | +/* daylight savings time modifier (solves "MET DST" syntax) */ |
2966 | 2976 | tmask |=DTK_M(DTZ);
|
2967 | 2977 | tm->tm_isdst=1;
|
2968 | 2978 | if (tzp==NULL)
|
@@ -3466,17 +3476,14 @@ DecodeNumber(int flen, char *str, int fmask,
|
3466 | 3476 | *tmask=DTK_M(YEAR);
|
3467 | 3477 |
|
3468 | 3478 | /* already have a year? then see if we can substitute... */
|
3469 |
| -if (fmask&DTK_M(YEAR)) |
| 3479 | +if ((fmask&DTK_M(YEAR))&& (!(fmask&DTK_M(DAY))) |
| 3480 | +&& ((tm->tm_year >=1)&& (tm->tm_year <=31))) |
3470 | 3481 | {
|
3471 |
| -if ((!(fmask&DTK_M(DAY))) |
3472 |
| -&& ((tm->tm_year >=1)&& (tm->tm_year <=31))) |
3473 |
| -{ |
| 3482 | +tm->tm_mday=tm->tm_year; |
| 3483 | +*tmask=DTK_M(DAY); |
3474 | 3484 | #ifdefDATEDEBUG
|
3475 |
| -printf("DecodeNumber- misidentified year previously;swap with day %d\n",tm->tm_mday); |
| 3485 | +printf("DecodeNumber- misidentified year previously;assign as day %d\n",tm->tm_mday); |
3476 | 3486 | #endif
|
3477 |
| -tm->tm_mday=tm->tm_year; |
3478 |
| -*tmask=DTK_M(DAY); |
3479 |
| -} |
3480 | 3487 | }
|
3481 | 3488 |
|
3482 | 3489 | tm->tm_year=val;
|
|