Fix bug in relative time specifications. Caused `now', `tomrrow',
authormdw <mdw>
Wed, 26 May 1999 09:28:44 +0000 (09:28 +0000)
committermdw <mdw>
Wed, 26 May 1999 09:28:44 +0000 (09:28 +0000)
etc. to bump the time by one minute.

getdate.y

index a11c0ac..4be26bf 100644 (file)
--- a/getdate.y
+++ b/getdate.y
@@ -91,7 +91,8 @@ static int yylex ();
 static int yyerror ();
 
 #define EPOCH          1970
-#define HOUR(x)                ((x) * 60)
+#define HOUR(x)                ((time_t)(x) * 60)
+#define SECSPERDAY     (24L * 60L * 60L)
 
 #define MAX_BUFF_LEN    128   /* size of buffer to read the date into */
 
@@ -319,7 +320,7 @@ relunit     : tUNUMBER tYEAR_UNIT {
            yyRelYear += $1 * $2;
        }
        | tYEAR_UNIT {
-           yyRelYear++;
+           yyRelYear += $1;
        }
        | tUNUMBER tMONTH_UNIT {
            yyRelMonth += $1 * $2;
@@ -328,7 +329,7 @@ relunit     : tUNUMBER tYEAR_UNIT {
            yyRelMonth += $1 * $2;
        }
        | tMONTH_UNIT {
-           yyRelMonth++;
+           yyRelMonth += $1;
        }
        | tUNUMBER tDAY_UNIT {
            yyRelDay += $1 * $2;
@@ -337,7 +338,7 @@ relunit     : tUNUMBER tYEAR_UNIT {
            yyRelDay += $1 * $2;
        }
        | tDAY_UNIT {
-           yyRelDay++;
+           yyRelDay += $1;
        }
        | tUNUMBER tHOUR_UNIT {
            yyRelHour += $1 * $2;
@@ -346,7 +347,7 @@ relunit     : tUNUMBER tYEAR_UNIT {
            yyRelHour += $1 * $2;
        }
        | tHOUR_UNIT {
-           yyRelHour++;
+           yyRelHour += $1;
        }
        | tUNUMBER tMINUTE_UNIT {
            yyRelMinutes += $1 * $2;
@@ -355,7 +356,7 @@ relunit     : tUNUMBER tYEAR_UNIT {
            yyRelMinutes += $1 * $2;
        }
        | tMINUTE_UNIT {
-           yyRelMinutes++;
+           yyRelMinutes += $1;
        }
        | tUNUMBER tSEC_UNIT {
            yyRelSeconds += $1 * $2;
@@ -364,7 +365,7 @@ relunit     : tUNUMBER tYEAR_UNIT {
            yyRelSeconds += $1 * $2;
        }
        | tSEC_UNIT {
-           yyRelSeconds++;
+           yyRelSeconds += $1;
        }
        ;
 
@@ -465,7 +466,7 @@ static TABLE const OtherTable[] = {
     { "now",           tMINUTE_UNIT,   0 },
     { "last",          tUNUMBER,       -1 },
     { "this",          tMINUTE_UNIT,   0 },
-    { "next",          tUNUMBER,       2 },
+    { "next",          tUNUMBER,       1 /* Was bogusly 2 [mdw] */ },
     { "first",         tUNUMBER,       1 },
 /*  { "second",                tUNUMBER,       2 }, */
     { "third",         tUNUMBER,       3 },