From: Tim Kientzle Date: Sat, 21 Feb 2009 07:22:59 +0000 (-0500) Subject: Minor fidgeting with the AM/PM parsing. X-Git-Tag: v2.7.0~233 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=030d77aa7af44e9a294ff6089eff1d50c361336e;p=thirdparty%2Flibarchive.git Minor fidgeting with the AM/PM parsing. SVN-Revision: 688 --- diff --git a/tar/getdate.y b/tar/getdate.y index 0d94aca22..4522c4f3a 100644 --- a/tar/getdate.y +++ b/tar/getdate.y @@ -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 tDAY tDAYZONE tMONTH tMONTH_UNIT -%type tSEC_UNIT tUNUMBER tZONE tAMPM +%type 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 },