FuzzyDate

this gem provides a ruby class for working with incomplete dates.

Gem

install gem

gem install fuzzy_date 

There is also an extension to the ActiveRecord::Base class to provide an ‘acts_as_fuzzy_date’ class method

Historical dates are often incomplete or approximate and this class allows
such dates to be worked with and stored on a database.

construct a new object with


FuzzyDate.new( year,month,day,wday,circa)

year: optional..is the year number 0 .. big as you like, -ve for BCE month: optional.. is month number 1..12, or nil day: optional.. is day number 1-31 or nil wday: optional.. day of the week – 0=Sunday .. 6=Saturday circa: true = daye is approx, or nil/false

note that if you supply the weekday and a year/month/day the system will use your weekday as supplied even if this does not actually correspond in reality to the date supplied.

construct a new object with:


FuzzyDate.parse(“date_string”)

date_string = eg: “tuesday” “12 nov 1012” “circa 412 bc”

Use in a database table by storing in an integer field of a format large enough to hold the digits of your maximum year + 8. Eg. a BIGNUM field stores 19 useful characters allowing the year to go to 99,999,999,999. ie 99 billion years.

Use with an ActiveRecord class ..

       require 'fuzzy_date'

       class HistoricalPerson < ActiveRecord::Base

           acts_as_fuzzy_date : birth_date, death_date

       end