int yyRelMonth;
int yyRelSeconds;
int yyRelYear;
- int yyFlag;
};
typedef union _date_ll {
%}
-/* This grammar has 19 shift/reduce conflicts. */
-%expect 19
+/* This grammar has 21 shift/reduce conflicts. */
+%expect 21
%pure_parser
+%debug
+
%token tAGO tDAY tDAY_UNIT tDAYZONE tDST tHOUR_UNIT tID tTZONE tZZONE
%token tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
%token tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT tZONE
} else {
((struct date_yy *)parm)->yyTimezone = -$6 * 60;
}
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER '.' tUNUMBER pgsqlzonepart {
+ }
+ | tUNUMBER ':' tUNUMBER ':' tUNUMBER '.' tUNUMBER pgsqlzonepart {
((struct date_yy *)parm)->yyHour = $1;
((struct date_yy *)parm)->yyMinutes = $3;
((struct date_yy *)parm)->yySeconds = $5;
((struct date_yy *)parm)->yyMeridian = MER24;
}
+ | iso8601time
;
+iso8601time: tUNUMBER ':' tUNUMBER ':' tUNUMBER {
+ ((struct date_yy *)parm)->yyHour = $1;
+ ((struct date_yy *)parm)->yyMinutes = $3;
+ ((struct date_yy *)parm)->yySeconds = $5;
+ ((struct date_yy *)parm)->yyMeridian = MER24;
+ }
+ ;
+
+
pgsqlzonepart : tSNUMBER {
((struct date_yy *)parm)->yyHaveZone++;
if ($1 <= -100 || $1 >= 100) {
*/
zone : tTZONE {
- ((struct date_yy *)parm)->yyFlag = 1;
((struct date_yy *)parm)->yyTimezone = $1;
}
| tZZONE {
- if (((struct date_yy *)parm)->yyFlag) {
- ((struct date_yy *)parm)->yyHaveZone--;
- ((struct date_yy *)parm)->yyFlag = 0;
- }
((struct date_yy *)parm)->yyTimezone = $1;
}
| tZONE {
((struct date_yy *)parm)->yyYear = $5;
}
}
- | tUNUMBER tSNUMBER tSNUMBER {
- /* ISO 8601 format. yyyy-mm-dd. */
- ((struct date_yy *)parm)->yyYear = $1;
- ((struct date_yy *)parm)->yyMonth = -$2;
- ((struct date_yy *)parm)->yyDay = -$3;
- }
+ | iso8601date
+ | iso8601date tTZONE iso8601time {
+ ((struct date_yy *)parm)->yyTimezone = 0;
+ ((struct date_yy *)parm)->yyHaveZone++;
+ ((struct date_yy *)parm)->yyHaveTime++;
+ }
+ | iso8601date tTZONE iso8601time tZZONE {
+ ((struct date_yy *)parm)->yyTimezone = 0;
+ ((struct date_yy *)parm)->yyHaveZone++;
+ ((struct date_yy *)parm)->yyHaveTime++;
+ }
| tUNUMBER tMONTH tSNUMBER {
/* e.g. 17-JUN-1992. */
((struct date_yy *)parm)->yyDay = $1;
}
;
+iso8601date: tUNUMBER tSNUMBER tSNUMBER {
+ /* ISO 8601 format. yyyy-mm-dd. */
+ ((struct date_yy *)parm)->yyYear = $1;
+ ((struct date_yy *)parm)->yyMonth = -$2;
+ ((struct date_yy *)parm)->yyDay = -$3;
+ }
+ ;
+
rel : relunit tAGO {
((struct date_yy *)parm)->yyRelSeconds =
-((struct date_yy *)parm)->yyRelSeconds;
date.yyHaveRel = 0;
date.yyHaveTime = 0;
date.yyHaveZone = 0;
- date.yyFlag = 0;
if (yyparse ((void *)&date)
|| date.yyHaveTime > 1 || date.yyHaveZone > 1
- || date.yyHaveDate > 1 || date.yyHaveDay > 1)
+ || date.yyHaveDate > 1 || date.yyHaveDay > 1) {
return -1;
-
+ }
tm.tm_year = ToYear (date.yyYear) - TM_YEAR_ORIGIN + date.yyRelYear;
tm.tm_mon = date.yyMonth - 1 + date.yyRelMonth;
tm.tm_mday = date.yyDay + date.yyRelDay;