@@ -117,18 +117,11 @@ static int yyDayNumber;
117117static int yyHaveDate;
118118static int yyHaveDay;
119119static int yyHaveRel;
120- static int yyHaveTime;
121120static int yyDay;
122- static int yyHour;
123- static int yyMinutes;
124121static int yyMonth;
125- static int yySeconds;
126122static int yyYear;
127123static int yyRelDay;
128- static int yyRelHour;
129- static int yyRelMinutes;
130124static int yyRelMonth;
131- static int yyRelSeconds;
132125static int yyRelYear;
133126
134127%}
@@ -137,24 +130,21 @@ static int yyRelYear;
137130 int Number;
138131}
139132
140- %token tAGO tDAY tDAY_UNIT tHOUR_UNIT tID
141- %token tMINUTE_UNIT tMONTH tMONTH_UNIT
142- %token tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT
133+ %token tAGO tDAY tDAY_UNIT tID
134+ %token tMONTH tMONTH_UNIT
135+ %token tSNUMBER tUNUMBER tYEAR_UNIT
143136
144- %type <Number> tDAY tDAY_UNIT tHOUR_UNIT tMINUTE_UNIT
137+ %type <Number> tDAY tDAY_UNIT
145138%type <Number> tMONTH tMONTH_UNIT
146- %type <Number> tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT
139+ %type <Number> tSNUMBER tUNUMBER tYEAR_UNIT
147140
148141%%
149142
150143spec : /* NULL */
151144 | spec item
152145 ;
153146
154- item : time {
155- yyHaveTime++;
156- }
157- | date {
147+ item : date {
158148 yyHaveDate++;
159149 }
160150 | day {
@@ -166,17 +156,6 @@ item : time {
166156 | number
167157 ;
168158
169- time : tUNUMBER ' :' tUNUMBER {
170- yyHour = $1 ;
171- yyMinutes = $3 ;
172- }
173- | tUNUMBER ' :' tUNUMBER ' :' tUNUMBER {
174- yyHour = $1 ;
175- yyMinutes = $3 ;
176- yySeconds = $5 ;
177- }
178- ;
179-
180159day : tDAY {
181160 yyDayOrdinal = 1 ;
182161 yyDayNumber = $1 ;
@@ -246,9 +225,6 @@ date : tUNUMBER '/' tUNUMBER {
246225 ;
247226
248227rel : relunit tAGO {
249- yyRelSeconds = -yyRelSeconds;
250- yyRelMinutes = -yyRelMinutes;
251- yyRelHour = -yyRelHour;
252228 yyRelDay = -yyRelDay;
253229 yyRelMonth = -yyRelMonth;
254230 yyRelYear = -yyRelYear;
@@ -283,64 +259,14 @@ relunit : tUNUMBER tYEAR_UNIT {
283259 | tDAY_UNIT {
284260 yyRelDay += $1 ;
285261 }
286- | tUNUMBER tHOUR_UNIT {
287- yyRelHour += $1 * $2 ;
288- }
289- | tSNUMBER tHOUR_UNIT {
290- yyRelHour += $1 * $2 ;
291- }
292- | tHOUR_UNIT {
293- yyRelHour += $1 ;
294- }
295- | tUNUMBER tMINUTE_UNIT {
296- yyRelMinutes += $1 * $2 ;
297- }
298- | tSNUMBER tMINUTE_UNIT {
299- yyRelMinutes += $1 * $2 ;
300- }
301- | tMINUTE_UNIT {
302- yyRelMinutes += $1 ;
303- }
304- | tUNUMBER tSEC_UNIT {
305- yyRelSeconds += $1 * $2 ;
306- }
307- | tSNUMBER tSEC_UNIT {
308- yyRelSeconds += $1 * $2 ;
309- }
310- | tSEC_UNIT {
311- yyRelSeconds += $1 ;
312- }
313262 ;
314263
315264number : tUNUMBER
316265 {
317- if ((yyHaveTime != 0 ) && (yyHaveDate != 0 ) && (yyHaveRel == 0 ))
318- yyYear = $1 ;
319- else
320- {
321- if ($1 >10000 )
322- {
323266 yyHaveDate++;
324267 yyDay= ($1 )%100 ;
325268 yyMonth= ($1 /100 )%100 ;
326269 yyYear = $1 /10000 ;
327- }
328- else
329- {
330- yyHaveTime++;
331- if ($1 < 100 )
332- {
333- yyHour = $1 ;
334- yyMinutes = 0 ;
335- }
336- else
337- {
338- yyHour = $1 / 100 ;
339- yyMinutes = $1 % 100 ;
340- }
341- yySeconds = 0 ;
342- }
343- }
344270 }
345271 ;
346272
@@ -382,22 +308,17 @@ static TABLE const UnitsTable[] = {
382308 { " fortnight" , tDAY_UNIT, 14 },
383309 { " week" , tDAY_UNIT, 7 },
384310 { " day" , tDAY_UNIT, 1 },
385- { " hour" , tHOUR_UNIT, 1 },
386- { " minute" , tMINUTE_UNIT, 1 },
387- { " min" , tMINUTE_UNIT, 1 },
388- { " second" , tSEC_UNIT, 1 },
389- { " sec" , tSEC_UNIT, 1 },
390311 { NULL , 0 , 0 }
391312};
392313
393314/* Assorted relative-time words. */
394315static TABLE const OtherTable[] = {
395- { " tomorrow" , tMINUTE_UNIT , 1 * 24 * 60 },
396- { " yesterday" , tMINUTE_UNIT , -1 * 24 * 60 },
397- { " today" , tMINUTE_UNIT , 0 },
398- { " now" , tMINUTE_UNIT , 0 },
316+ { " tomorrow" , tDAY_UNIT , 1 },
317+ { " yesterday" , tDAY_UNIT , -1 },
318+ { " today" , tDAY_UNIT , 0 },
319+ { " now" , tDAY_UNIT , 0 },
399320 { " last" , tUNUMBER, -1 },
400- { " this" , tMINUTE_UNIT , 0 },
321+ { " this" , tDAY_UNIT , 0 },
401322 { " next" , tUNUMBER, 2 },
402323 { " first" , tUNUMBER, 1 },
403324/* { "second", tUNUMBER, 2 }, */
@@ -579,43 +500,21 @@ time_t get_date (const char *p, const time_t *now)
579500 yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
580501 yyMonth = tmp->tm_mon + 1 ;
581502 yyDay = tmp->tm_mday ;
582- yyHour = tmp->tm_hour ;
583- yyMinutes = tmp->tm_min ;
584- yySeconds = tmp->tm_sec ;
585- yyRelSeconds = 0 ;
586- yyRelMinutes = 0 ;
587- yyRelHour = 0 ;
588503 yyRelDay = 0 ;
589504 yyRelMonth = 0 ;
590505 yyRelYear = 0 ;
591506 yyHaveDate = 0 ;
592507 yyHaveDay = 0 ;
593508 yyHaveRel = 0 ;
594- yyHaveTime = 0 ;
595509
596510 if (yyparse ()
597- || yyHaveTime > 1 || yyHaveDate > 1 || yyHaveDay > 1 )
511+ || yyHaveDate > 1 || yyHaveDay > 1 )
598512 return -1 ;
599513
600514 tm.tm_year = ToYear (yyYear) - TM_YEAR_ORIGIN + yyRelYear;
601515 tm.tm_mon = yyMonth - 1 + yyRelMonth;
602516 tm.tm_mday = yyDay + yyRelDay;
603- if ((yyHaveTime != 0 ) ||
604- ( (yyHaveRel != 0 ) && (yyHaveDate == 0 ) && (yyHaveDay == 0 ) ))
605- {
606- tm.tm_hour = yyHour;
607- if (tm.tm_hour < 0 )
608- return -1 ;
609- tm.tm_min = yyMinutes;
610- tm.tm_sec = yySeconds;
611- }
612- else
613- {
614- tm.tm_hour = tm.tm_min = tm.tm_sec = 0 ;
615- }
616- tm.tm_hour += yyRelHour;
617- tm.tm_min += yyRelMinutes;
618- tm.tm_sec += yyRelSeconds;
517+ tm.tm_hour = tm.tm_min = tm.tm_sec = 0 ;
619518 tm.tm_isdst = 0 ;
620519
621520 Start = timegm (&tm);
0 commit comments