[PATCH 0/4] Versatile date/time parser

Michal Sojka sojkam1 at fel.cvut.cz
Sun Jan 23 03:47:23 PST 2011


Hi all,

the following patch series brings into notmuch date/time parser stolen
from GNU coreutils. It can be applied on top of custom query parser
patches from Austin Clements.

This is RFC and it not meant for merging.

With these patches you can specify the date/time in many ways such as:
after:"last monday", after:"2 hours ago", etc. There are some
problems, though.

1) The parser is meant for parsing time instant specifications, which
   not convenient for use with before/after prepositions. For example
   after:"last Tuesday" should mean Wednesday, Thursday etc. and
   before:"last Tuesday" should mean Monday, Sunday, etc.

   Currently, "last Tuesday" means "Tuesday 00:00" and therefore,
   after:"last Tuesday" also matches mails sent on Tuesday.

2) "yesterday" means "24 hours ago" and not "yesterday midnight" as I
   would expect.

3) "Tuesday" means the "next Tuesday" instead of the "last Tuesday",
   which is natural in the context of emails (usually, there are no
   mails with future dates).

I think that all these problems could be fixed in the parser, but
maybe some others do not see them as problems or there might be a
better parser available for us to use. What do you think?

In any way, if anybody wants to try it, the whole patch serie (custom
query parser + date parse (without cworth's folder-based search)) is
available from my git repository:

   git pull git://rtime.felk.cvut.cz/notmuch.git date-parser

If we decide to use this parser, we might also want to reduce its
dependencies a bit. Since it is able to run even on DOS, there are
many compatibility functions included.

-Michal   

Michal Sojka (4):
  Import date/time parser from GNU coreutils
  Compile the date/time parser into notmuch library
  Use the time/date parser for after: and before: prefixes
  Add first date parser tests

 Makefile.local      |    3 +
 configure           |    8 +
 lib/Makefile.local  |    5 +-
 lib/c-ctype.c       |  398 ++++++
 lib/c-ctype.h       |  297 +++++
 lib/config.h        |   45 +
 lib/database.cc     |   14 +-
 lib/getdate.c       | 3534 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/getdate.h       |   31 +
 lib/getdate.y       | 1609 +++++++++++++++++++++++
 lib/gettime.c       |   48 +
 lib/intprops.h      |   83 ++
 lib/timespec.h      |   39 +
 lib/verify.h        |  140 ++
 test/Makefile.local |    9 +-
 test/basic          |    2 +-
 test/date-parser    |   37 +
 test/notmuch-test   |    2 +-
 18 files changed, 6293 insertions(+), 11 deletions(-)
 create mode 100644 lib/c-ctype.c
 create mode 100644 lib/c-ctype.h
 create mode 100644 lib/config.h
 create mode 100644 lib/getdate.c
 create mode 100644 lib/getdate.h
 create mode 100644 lib/getdate.y
 create mode 100644 lib/gettime.c
 create mode 100644 lib/gettime.h
 create mode 100644 lib/intprops.h
 create mode 100644 lib/timespec.h
 create mode 100644 lib/verify.h
 create mode 100755 test/date-parser

-- 
1.7.2.3



More information about the notmuch mailing list