88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.113 2003/08/08 21:42:05 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.114 2003/08/25 22:47:34 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -243,7 +243,7 @@ static datetkn datetktbl[] = {
243243ghst
244244#endif
245245{"gilt" ,TZ ,POS (48 )},/* Gilbert Islands Time */
246- {"gmt" ,TZ ,POS (0 )},/*Greenwish Mean Time */
246+ {"gmt" ,TZ ,POS (0 )},/*Greenwich Mean Time */
247247{"gst" ,TZ ,POS (40 )},/* Guam Std Time, USSR Zone 9 */
248248{"gyt" ,TZ ,NEG (16 )},/* Guyana Time */
249249{"h" ,UNITS ,DTK_HOUR },/* "hour" */
@@ -1989,7 +1989,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
19891989 * Set the type field to allow decoding other
19901990 * fields later. Example: 20011223 or 040506
19911991 */
1992- if ((ftype [i ]= DecodeNumberField (flen ,field [i ],fmask ,
1992+ if ((ftype [i ]= DecodeNumberField (flen ,field [i ],
1993+ (fmask |DTK_DATE_M ),
19931994& tmask ,tm ,fsec ,& is2digits ))< 0 )
19941995return -1 ;
19951996}
@@ -1998,12 +1999,14 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
19981999}
19992000else if (flen > 4 )
20002001{
2001- if ((ftype [i ]= DecodeNumberField (flen ,field [i ],fmask ,
2002+ if ((ftype [i ]= DecodeNumberField (flen ,field [i ],
2003+ (fmask |DTK_DATE_M ),
20022004& tmask ,tm ,fsec ,& is2digits ))< 0 )
20032005return -1 ;
20042006}
20052007/* otherwise it is a single date/time field... */
2006- else if (DecodeNumber (flen ,field [i ],fmask ,
2008+ else if (DecodeNumber (flen ,field [i ],
2009+ (fmask |DTK_DATE_M ),
20072010& tmask ,tm ,fsec ,& is2digits )!= 0 )
20082011return -1 ;
20092012}
@@ -2422,8 +2425,12 @@ DecodeNumber(int flen, char *str, int fmask,
24222425 * or a run-together time: 2001.360 20011225 040506.789
24232426 */
24242427if ((cp - str )> 2 )
2425- return DecodeNumberField (flen ,str , (fmask |DTK_DATE_M ),
2426- tmask ,tm ,fsec ,is2digits );
2428+ {
2429+ if (DecodeNumberField (flen ,str , (fmask |DTK_DATE_M ),
2430+ tmask ,tm ,fsec ,is2digits )< 0 )
2431+ return -1 ;
2432+ return 0 ;
2433+ }
24272434
24282435frac = strtod (cp ,& cp );
24292436if (* cp != '\0' )
@@ -2507,6 +2514,13 @@ DecodeNumber(int flen, char *str, int fmask,
25072514tm -> tm_mday = val ;
25082515break ;
25092516
2517+ case (DTK_M (YEAR ) |DTK_M (MONTH ) |DTK_M (DAY )):
2518+ /* we have all the date, so it must be a time field */
2519+ if (DecodeNumberField (flen ,str ,fmask ,
2520+ tmask ,tm ,fsec ,is2digits )< 0 )
2521+ return -1 ;
2522+ return 0 ;
2523+
25102524default :
25112525/* Anything else is bogus input */
25122526return -1 ;