Forum: Ruby on Rails Date/Time Quick Add

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Fee443fff07e54e3cbb3acda0bc05af2?d=identicon&s=25 stirman (Guest)
on 2006-05-17 00:07
I am building a small app that reuires some clever text pattern

In my controller, I'll have a string that I will want to parse out to a
datetime and a message, a la Google Calendar Quick Add.


10/30/2006 7pm message
10-30-96 7:00 pm message
10/30/2006 19:00pm message

You see what I'm getting at.  For a v1.0 release, I CAN publish some
standards for users to adhere to regarding how the string should look,
but I'm wondering how some more experienced programmers might attack
this problem, from a high level view.  What do you initially look for,
what do you delimit on, how do you break the string up, etc.

Would love some feedback, many thanks in advance!

631d1677786f0725da6ccee46043686e?d=identicon&s=25 Jonathan Viney (Guest)
on 2006-05-17 02:59
(Received via mailing list)
Have a look at my validates_date_time plugin

34f5b045aec62235c17458650ea75353?d=identicon&s=25 Steve Koppelman (hatless)
on 2006-05-17 04:16
Jeepers, that's pretty nice.

Have you looked at DateboxEngine?

It only handles dates, not times, and does it in Javascript..  but you
might want to investigate some of the patterns it recognizes, like "next
tuesday", "last monday" and month and date with an implicit year.

Jonathan Viney wrote:
> Have a look at my validates_date_time plugin
> -Jonathan.
631d1677786f0725da6ccee46043686e?d=identicon&s=25 Jonathan Viney (Guest)
on 2006-05-17 07:48
(Received via mailing list)
I've found that most users don't want to type 'today', and as I
usually give them a date picker widget they're pretty happy to just
use that.

I wouldn't be adverse to adding support to parse more english-like
dates such as 'today', 'last tuesday' etc..., feel free to write a
patch if you want.

Parsing with an implicit year is a good idea, I may add that at some
stage. Again, patches welcome :).

Cheers, Jonathan.
Fee443fff07e54e3cbb3acda0bc05af2?d=identicon&s=25 stirman (Guest)
on 2006-05-17 16:02
Wow, great plugin...

Today I'll be sorting through the code to see how I can apply it to my

As I learn what you did, I'll see about writing a patch to include some
of the above-mentioned functionality.

Many thanks, great work.

This topic is locked and can not be replied to.