Change Log for Ruby-units ========================= 2006-08-22 0.1.0 * Initial Release 2006-08-22 0.1.1 * Added new format option "1 mm".to_unit("in") now converts the result to the indicated units * Fixed some naming issues so that the gem name matches the require name. * Added CHANGELOG * Improved test coverage (100% code coverage via RCov) * fixed a bug that prevented units with a prefix in the denominator from converting properly * can use .unit method on a string to create a new unit object * can now coerce or define units from arrays, strings, numerics. "1 mm".unit + [1, 'mm'] === "2 mm".unit [1,'mm','s'].unit === "1 mm/s".unit 2.5.unit === "2.5".unit * Added instructions on how to add custom units 2006-08-28 0.2.0 * Added 'ruby_unit.rb' file so that requires will still work if the wrong name is used * Added 'to' as an alias to '>>' so conversions can be done as '1 m'.unit.to('1 cm') * Added ability to convert temperatures to absolute values using the following syntax: '37 degC'.unit.to('tempF') #=> '98.6 degF'.unit * Tweaked abbreviations a bit. 'ton' is now 'tn' instead of 't'. It was causing parse collisions with 'atm'. * fixed a bug in term elimination routine * fixed a bug in parsing of powers, and added support for 'm**2' format * Added support for taking roots of units. Just exponentiate with a fraction (0.5, 1.0/3, 0.25) * renamed 'quantity' to 'scalar' * any type of Numeric can be used to initialize a Unit, although this can't really be done with a string * Units can not be forced to a float using to_f unless they are unitless. This prevents some math functions from forcing the conversion. To get the scalar, just use 'unit.scalar' * 'inspect' returns string representation * better edge-case detection with math functions. "0 mm".unit**-1 now throws a ZeroDivisionError exception * Ranges can make a series of units, so long as the end points have integer scalars. * Fixed a parsing bug with feet/pounds and scientific numbers 2006-09-17 * can now use the '%' format specifier like '%0.2f' % '1 mm'.unit #=> '1.00 mm' * works nicely with time now. '1 week'.unit + Time.now => 1.159e+09 s Time.at('1.159e+09 s'.unit) => Sat Sep 23 04:26:40 EDT 2006 "1.159e9 s".unit.time => Sat Sep 23 04:26:40 EDT 2006 * Time.now.unit => 1.159e9 s * works well with 'Uncertain' numerics (www.rubyforge.org/projects/uncertain) * Improved parsing 2006-09-18 0.2.1 * Trig math functions (sin, cos, tan, sinh, cosh, tanh) accept units that can be converted to radians Math.sin("90 deg".unit) => 1.0 * Date and DateTime can be offset by a time unit (Date.today + "1 day".unit) => 2006-09-19 Does not work with months since they aren't a consistent size * Tweaked time usage a bit Time.now + "1 hr".unit => Mon Sep 18 11:51:29 EDT 2006 * can output time in 'hh:mm:ss' format by using 'unit.to_s(:time)' * added time helper methods ago, since(Time/DateTime), until(Time/DateTime), from(Time/DateTime), before(Time/DateTime), and after(Time/DateTime) * Time helpers also work on strings. In this case they are first converted to units '5 min'.from_now '1 week'.ago 'min'.since(time) 'min'.until(time) '1 day'.from() * Can pass Strings to time helpers and they will be parsed with ParseDate * Fixed most parsing bugs (I think) * Can pass a strftime format string to to_s to format time output * can use U'1 mm' or '1 mm'.u to specify units now 2006-09-19 0.2.2 * tweaked temperature handling a bit. Now enter temperatures like this: '0 tempC'.unit #=> 273.15 degK They will always be converted to kelvin to avoid problems when temperatures are used in equations. * added Time.in("5 min") * added Unit.to_unit to simplify some calls 2006-09-22 0.2.3 * added support for date/time parsing with the Chronic gem parsing will use Chronic if it is loaded * allows Date / Time / DateTime conversions * better test coverage * The 'string'.to_time returns a Time object * 'string'.to_datetime returns a DateTime object * 'string'.time returns a Time object or a DateTime if the Time object fails * 'string'.datetime returns a DateTime or a Time if the DateTime fails 2006-10-02 0.3.0 * Performance enhanced by caching results of many functions (Thanks to Kurt Stephens for pushing this.) * Throws an exception if the unit is not recognized * units can now identify what 'kind' they are (:length, :mass, etc..) * New constructors: Unit(1,"mm") Unit(1,"mm/s") Unit(1,"mm","s") 2006-10-02 0.3.1 * minor bug fixes 2006-10-03 0.3.2 * More minor bug fixes (now fixes a minor name collision with rails) 2006-10-03 0.3.3 * Apparently I can't do math late at night. Fixed a bug that would cause problems when adding or subtracting units to a unit with a zero scalar. * Date and DateTime objects can be converted to 'units' 2006-10-27 0.3.4 * Fixed a few more parsing bugs so that it will properly complain about malformed units. * Fixed a bug that prevents proper use of percents * several minor tweaks * some improved Date and DateTime handling * can convert between Date, DateTime, and Time objects * Time math will now return a DateTime if it goes out of range. 2006-11-20 0.3.5 * Minor bug fixes * to_int now coerces the result to an actual Integer, but only works properly for unitless Units. 2006-12-05 0.3.6 * Fixed bug where (unit/unit).ceil would fail 2006-12-14 0.3.7 * improved handling of percents and added a 'wt%' unit equivalent to 1 g/dl. * Improved handling for units with non-alphanumeric names (like ' for feet, # for pound) * Now you can enter durations as "HH:MM:SS, usec" or "HH:MM:SS:usec"