lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 19 March 2012 21:23, Alexander Gladysh <agladysh@gmail.com> wrote:
> On Tue, Mar 20, 2012 at 01:13, liam mail <liam.list@googlemail.com> wrote:
>> On 19 March 2012 21:06, Alexander Gladysh <agladysh@gmail.com> wrote:
>
>>>> strptime[1] or maybe another implementation such as [2] which is BSD
>
>>> How would this help me to parse "yesterday" or "week ago" as a date?
>
>> Well for them you could just adjust the tm struct which is ANSI.
>
> Yes, of course. But I'd have to decide on specs for these phrases,
> code the parser, write a bunch of tests... Lots of work, no time. A
> third-party library would be preferable. Or a fellow open-source
> community to help design and write one at least :-)
>

Just for completeness, I have written a library along these lines,
based on LPEG. It needs some work (I'm not currently using it in any
active project), but it has tests for the stuff I needed it for when I
wrote it. One small catch is that it is geared towards future dates
("in a week", "next Monday", "tomorrow morning", ...), and it sounds
like you're more interested in past dates.

It was aimed around parsing natural language reminders, so can split
out the time from phrases like "Go fishing tomorrow afternoon", so you
can also work out the actual reminder text.

It's obviously not really an open-source project because it's not on
github. But if you are interested, you can find it at
http://code.matthewwild.co.uk/ndp/

I realise I've neglected licence info (MIT of course), so I'll add that now.

Regards,
Matthew