public
Description: rails plugin for parsing date ranges out of strings
Homepage:
Clone URL: git://github.com/arturaz/date_range.git
arturaz (author)
Sun Oct 19 04:05:09 -0700 2008
commit  0469d2ec930416f0f9ead377420eceb0b0d8b78e
tree    f2dc5e840f3cba370911b276ab1d4aed0589e09f
parent  3e9a9db08413b8b460beee7d111568c89bb0352e
name age message
file .gitignore Loading commit data...
file README.rdoc
file Rakefile Sat Oct 18 17:27:42 -0700 2008 Initial import. [arturaz]
directory lib/
directory spec/
README.rdoc

DateRange

Simple plugin for parsing out date ranges from user input.

Example

  DateRange.parse("2008 - 2010")

will give you Array consisting of 2 elements: [start_of_range, end_of_range].

It is pretty clever about recognizing what user wants, just check out the code to see all the things it does.

It will return nil if one of the times are corrupt (like 13th month) or missing.

It will also look at context if no end time is given so:

  • 2008 becomes 2008-01-01 00:00:00 - 2008-12-31 23:59:59
  • 2008-01 becomes 2008-01-01 00:00:00 - 2008-01-31 23:59:59
  • 2008-01-01 becomes 2008-01-01 00:00:00 - 2008-01-01 23:59:59</tt>
  • and so forth…

Copyright © 2008 Artūras Šlajus <x11@arturaz.net>, released under the MIT license