Mercurial > hg > octave-kai > gnulib-hg
changeset 15662:410c1c383d50
date: accept 'hence' as opposite of 'ago'
* lib/parse-datetime.y (relative_time_table): Add 'hence'.
* tests/test-parse-datetime.c (main): Enhance test.
Suggested by Jesse Wilson.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Fri, 16 Sep 2011 14:52:54 -0600 |
parents | 0aac3aa8d8fd |
children | 2234b0721604 |
files | ChangeLog lib/parse-datetime.y tests/test-parse-datetime.c |
diffstat | 3 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-09-19 Eric Blake <eblake@redhat.com> + + date: accept 'hence' as opposite of 'ago' + * lib/parse-datetime.y (relative_time_table): Add 'hence'. + * tests/test-parse-datetime.c (main): Enhance test. + Suggested by Jesse Wilson. + 2011-09-19 Jim Meyering <meyering@redhat.com> getcwd: don't fail in a deep directory on a system without openat
--- a/lib/parse-datetime.y +++ b/lib/parse-datetime.y @@ -296,7 +296,8 @@ relative_time rel; } -%token tAGO tDST +%token <intval> tAGO +%token tDST %token tYEAR_UNIT tMONTH_UNIT tHOUR_UNIT tMINUTE_UNIT tSEC_UNIT %token <intval> tDAY_UNIT tDAY_SHIFT @@ -544,7 +545,7 @@ rel: relunit tAGO - { apply_relative_time (pc, $1, -1); } + { apply_relative_time (pc, $1, $2); } | relunit { apply_relative_time (pc, $1, 1); } | dayshift @@ -733,7 +734,8 @@ { "TENTH", tORDINAL, 10 }, { "ELEVENTH", tORDINAL, 11 }, { "TWELFTH", tORDINAL, 12 }, - { "AGO", tAGO, 1 }, + { "AGO", tAGO, -1 }, + { "HENCE", tAGO, 1 }, { NULL, 0, 0 } };
--- a/tests/test-parse-datetime.c +++ b/tests/test-parse-datetime.c @@ -327,6 +327,8 @@ ASSERT (!parse_datetime (&result, p, &now)); p = "UTC+4:00 tomorrow ago"; ASSERT (!parse_datetime (&result, p, &now)); + p = "UTC+4:00 tomorrow hence"; + ASSERT (!parse_datetime (&result, p, &now)); p = "UTC+4:00 40 now ago"; ASSERT (!parse_datetime (&result, p, &now)); p = "UTC+4:00 last tomorrow"; @@ -345,6 +347,11 @@ LOG (p, now, result2); ASSERT (result.tv_sec == result2.tv_sec && result.tv_nsec == result2.tv_nsec); + p = "UTC+400 1 day hence"; + ASSERT (parse_datetime (&result2, p, &now)); + LOG (p, now, result2); + ASSERT (result.tv_sec == result2.tv_sec + && result.tv_nsec == result2.tv_nsec); now.tv_sec = 4711; now.tv_nsec = 1267; p = "UTC+400 yesterday";