Support for Float.years

Hi All,

There are some scientific data sets that use floating-point numbers for years, and I’ve been thinking about adding this to Rails.

For instance, the ice core CO2 measurements here uses the standard “Years Before Present” unit, which is floating point by default.

At present there is no way (to my knowledge) to ingest these values cleanly into Rails.

If there is interest in merging something to adapt the .years method for use with Floats so that scientific data sets like these can be more easily handled in Rails, I can prepare a PR.


I believe ActiveSupport is (and should be) focused on helpers needed by Rails, or a large majority of Rails user.

I think this would be better as a RubyGem rather than a core ActiveSupport patch.

Worth exploring! It’s often expected that methods like these work with any Numeric. The float case comes up when you do duration math, like “10% of N years” or “average age of X.”