lua-users home
lua-l archive

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


On Tue, Mar 20, 2012 at 02:32, Alexander Gladysh <agladysh@gmail.com> wrote:
> On Tue, Mar 20, 2012 at 02:22, Matthew Wild <mwild1@gmail.com> wrote:
>> 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.
>
> I'm interested in both, actually.

Also, I'm interested in parsing exact dates, which you do not handle
as well. Would be nice to incorporate that in the LPEG pattern itself,
not to call strptime.

Alexander.