Forum: Ruby on Rails Really old dates in rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
863afbc9c546135623e24de356268ac6?d=identicon&s=25 MartOn (Guest)
on 2008-11-11 22:08
(Received via mailing list)
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
D69d23d8e811e8ab2a8593380d6ede63?d=identicon&s=25 Jeff Emminger (jemminger)
on 2008-11-11 22:14
(Received via mailing list)
DateTime can
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2008-11-11 23:38
(Received via mailing list)
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 Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
863afbc9c546135623e24de356268ac6?d=identicon&s=25 MartOn (Guest)
on 2008-11-11 23:49
(Received via mailing list)
Yup. that was correct.
I am using hobo in Rails, so the bug is in Hobo, not Rails :-)

sorry
/MartOn
This topic is locked and can not be replied to.