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
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
DateTime can
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
Yup. that was correct.
I am using hobo in Rails, so the bug is in Hobo, not Rails
sorry
/MartOn
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs