]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Minor fidgeting with the AM/PM parsing.
authorTim Kientzle <kientzle@gmail.com>
Sat, 21 Feb 2009 07:22:59 +0000 (02:22 -0500)
committerTim Kientzle <kientzle@gmail.com>
Sat, 21 Feb 2009 07:22:59 +0000 (02:22 -0500)
SVN-Revision: 688

tar/getdate.y

index 0d94aca22c2fd23fbe7e5f2b4656277396d89119..4522c4f3a9fb42572d97e23a623a40bae449c42b 100644 (file)
@@ -62,11 +62,6 @@ typedef enum _DSTMODE {
     DSTon, DSToff, DSTmaybe
 } DSTMODE;
 
-/*
-**  Meridian:  am or pm.
-*/
-enum { tAM, tPM };
-
 /*
 **  Global variables.  We could get rid of most of these by using a good
 **  union as the yacc stack.  (This routine was originally written before
@@ -99,11 +94,11 @@ static time_t       yyRelSeconds;
     time_t             Number;
 }
 
-%token tAGO tDAY tDAYZONE tAMPM tMONTH tMONTH_UNIT tSEC_UNIT tUNUMBER
+%token tAGO tDAY tDAYZONE tAM tPM tMONTH tMONTH_UNIT tSEC_UNIT tUNUMBER
 %token  tZONE tDST
 
 %type  <Number>        tDAY tDAYZONE tMONTH tMONTH_UNIT
-%type  <Number>        tSEC_UNIT tUNUMBER tZONE tAMPM
+%type  <Number>        tSEC_UNIT tUNUMBER tZONE
 
 %%
 
@@ -119,24 +114,33 @@ item      : time { yyHaveTime++; }
        | number
        ;
 
-time   : tUNUMBER tAMPM {
+time   : tUNUMBER tAM {
                /* "7am" */
                yyHour = $1;
+               yyMinutes = 0;
+               yySeconds = 0;
                if (yyHour == 12)
                        yyHour = 0;
+       }
+       | tUNUMBER tPM {
+               /* "7pm" */
+               yyHour = $1;
                yyMinutes = 0;
                yySeconds = 0;
-               if ($2 == tPM)
+               if (yyHour < 12)
                        yyHour += 12;
        }
        | bare_time {
                /* "7:12:18" "19:17" */
        }
-       | bare_time tAMPM {
-               /* "7:12pm", "12:20:13am" */
+       | bare_time tAM {
+               /* "12:20:13am" */
                if (yyHour == 12)
                        yyHour = 0;
-               if ($2 == tPM)
+       }
+       | bare_time tPM {
+               /* "7:12pm" */
+               if (yyHour < 12)
                        yyHour += 12;
        }
        | bare_time  '+' tUNUMBER {
@@ -339,8 +343,8 @@ static struct TABLE {
        time_t          value;
 } const TimeWords[] = {
        /* am/pm */
-       { 0, "am",              tAMPM,  tAM },
-       { 0, "pm",              tAMPM,  tPM },
+       { 0, "am",              tAM,    0 },
+       { 0, "pm",              tPM,    0 },
 
        /* Month names. */
        { 3, "january",         tMONTH,  1 },