Really old dates in rails


#1

Hello
Im planning to store really old dates, but it seems Rails are having
trouble with that.
Are there any date types I can use that support dates older than for
instance 1900?

/MartOn


#2

DateTime can


#3

On Nov 11, 2008, at 4:13 PM, jemminger wrote:

/MartOn
Since you said really old dates, why not use Date?

------------------------------------------------------------ Class: Date
Class representing a date.

  See the documentation to the file date.rb for an overview.

  Internally, the date is represented as an Astronomical Julian Day
  Number, ajd. The Day of Calendar Reform, sg, is also stored, for
  conversions to other date formats. (There is also an of field for
  a time zone offset, but this is only for the use of the DateTime
  subclass.)

  A new Date object is created using one of the object creation
  class methods named after the corresponding date format, and the
  arguments appropriate to that date format; for instance,
  Date::civil() (aliased to Date::new()) with year, month, and
  day-of-month, or Date::ordinal() with year and day-of-year. All of
  these object creation class methods also take the Day of Calendar
  Reform as an optional argument.

  Date objects are immutable once created.

  Once a Date has been created, date values can be retrieved for the
  different date formats supported using instance methods. For
  instance, #mon() gives the Civil month, #cwday() gives the
  Commercial day of the week, and #yday() gives the Ordinal day of
  the year. Date values can be retrieved in any format, regardless
  of what format was used to create the Date instance.

  The Date class includes the Comparable module, allowing date
  objects to be compared and sorted, ranges of dates to be created,
  and so forth.

You probably want to store them in some database, too, I imagine so
you want to be aware of how your database treats dates. Depending on
your range, MySQL’s DATE or DATETIME may be useful.

-Rob

Rob B. http://agileconsultingllc.com
removed_email_address@domain.invalid


#4

Yup. that was correct.
I am using hobo in Rails, so the bug is in Hobo, not Rails :slight_smile:

sorry
/MartOn