[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: date.js in Lua?
- From: Alexander Gladysh <agladysh@...>
- Date: Tue, 20 Mar 2012 02:32:35 +0400
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.
> 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.
Not an open-source project that is as comfortable to use for some
spoiled persons as it could be. :-)
> But if you are interested, you can find it at
> http://code.matthewwild.co.uk/ndp/
I'm interested, thank you.
It worries me though that your tests rely on per-second difference. Do
you handle leap years etc.?
Also, I see no tests on bad input. (Okay, okay, work in progress, no
problem :-) )
> I realise I've neglected licence info (MIT of course), so I'll add that now.
That's the reason why this is not an open-source project, not hosting
:-) Please do.
Thanks,
Alexander.