- Timerizer now only supports Ruby 2.4+. While earlier Ruby versions may still work, Ruby 2.4 is the oldest release that is still receiving security updates. So, you should update if you haven't already!
- #10 (@muellerj): Fix warnings for Ruby 2.6 and update libraries
- #9 (@jdickey): Hotfix for issue preventing the library to load due to incorret gemspec configuration
- #8 (@jdickey): Added
Duration#to_rounded_sto convert a duration to a human-readable string by rounding the duration first. This provides a more natural representation of a string.- The default format of
#to_rounded_sis the new:min_longformat, which is similar to the:longformat except it excludes weeks.
- The default format of
- Timerizer now only supports Ruby 2.0+!
RelativeTimeis nowTimerizer:Duration. If you used the explicitRelativeTimeconstructor, you will need to update your code accordingly when updating to Timerizer 0.3.0+!WallClockhas moved into theTimerizermodule, so if you were usingWallClock, all references will need to be updated toTimerizer::WallClock!- The two-argument constructor of
RelativeTimehas been removed (i.e:RelativeTime.new(5, :minutes)). The equivalent withDurationnow uses a hash:Timerizer::Duration.new(minutes: 5) RelativeTime#average,RelativeTime#average!,RelativeTime#unaverageandRelativeTime#unaverage!are no more. The equivalent methods are nowDuration#denormalize(replacing#unaverage) andDuration#normalize(replacing#average), and both mutating versions are no more. Note that#average/#unaveragedo not give the same results as#denormalize/#normalize, so be wary if you depended on the exact values.- Remove
RelativeTime#{unit}andRelativeTime#in_{unit}methods. These methods never really worked as intended (as seen in issue #6). The closest equivalents areDuration#to_unitmethod (which takes a unit as a symbol), and theDuration#to_{unit}methods (#to_seconds,#to_minutes, etc.) . These methods live under a different name because the results differ from the former#in_{unit}/#{unit}methods. - The
units,units_in_secondsandunits_in_monthsclass methods fromRelativeTimehave been removed. See the newDuration::UNITSandDuration::UNIT_ALIASESconstants for a replacement. - Comparisons on
Durationdiffer from the former comparisons onRelativeTime. Durations are normalized before comparing, so some equality tests may now returntrue(for example,30.days == 1.monthnow returns true due to normalization).
- Timerizer now depends on Ruby 2.0+
RelativeTimeis nowDurationDurationandWallClockhave been moved into the newTimerizermoduleDuration#newhas been reworked. It now takes a single hash mapping units to unit quantities. Unlike the old constructor, it takes arbitrary units now, not just:secondsand:months.Duration#to_snow uses"mo"as a shorthand instead of"mn".Duration#to_swill now never return decades, centuries, or millennia in the default string formats. The changes toDuration#to_snow accept user-defined formatters, so clients can restore the old behavior with a custom formatter if needed.Duration#to_snow normalizes and denormalizes before printing. This means30.days.to_swill be equivalent to1.month.to_sby default.Duration#==now normalizes before comparison, so some comparions may be true that were false previously.
- Added
Duration#to_unitto convert a duration to a specific unit.#to_unitnormalizes the duration, so return values are more intuitive than the old conversion methods (for example,1.month.to_unit(:seconds)returns30). - Added
Duration#to_unitsto convert a duration to multiple significant units. This is similar toDuration#to_unit, except it can return multiple units at once. Example:90.minutes.to_units(:hours, :minutes)returns{hours: 1, minutes: 30}. See the docs for more details. - Add
Duration#to_{unit}helper methods (#to_seconds,#to_minutes, etc.). - Added new
Duration#normalizeandDuration#denormalizeto convert between second-based and month-based units. Durationnow implements#<=>andComparableto get all comparison operators (instead of just==and!=).Durationnow supports representing negative durations of time.Durationnow implements#-@(unary negation).Durationnow implements#*(multiplication) and#/(divison) to multiply and divide by scalar values (currently onlyIntegers are supported).Duration#to_snow takes user-defined options. See the docs for more details.
Duration#to_sno longer returns""(empty string) for empty durations (such as0.seconds). If all units are empty, the returned string will be"0 seconds"(or equivalent based on formatting options).- The new
Duration#to_{unit}conversion methods fix conversions between second-based and month-based units by normalizing units first. This resolves issue #6.
RelativeTime#average,RelativeTime#average!,RelativeTime#unaverage, andRelativeTime#unaverage!have been removed.Duration#denormalizeandDuration#normalizeshould now be used instead.RelativeTime#in_{unit}methods (#in_seconds,#in_minutes, etc.) have been removed.Duration#to_{unit}should be used instead, but note that the replacements may not return the same results as the oldRelativeTimeequivalents.RelativeTime#{unit}methods (#seconds,#minutes, etc.) have been removed. These methods weren't very well defined, but roughly were designed to "extract" the given unit from theRelativeTime. In general, these can be replaced byDuration#to_unitsto break down a duration into multiple units, then using#fetchor#[]on the resulting hash to get the specific desired unit (that is,relative_time.minutesis roughly equivalent toduration.to_units(:hours, :minutes).fetch(:minutes)).
- Relicensed project as MIT! Huge thanks to @cesarfigueroa and @elifoster for allowing their patches to be relicensed!
- Fixed metadata in
timerizer.gemspec. Most previous version showed up as published at a different date on RubyGems due to this misconfiguration. This should now be fixed for any future relases.
- Use
Integerinstead ofFixnum(for Ruby 2.4+ compatibility)
- Add
WallClock#from_stringto parse a string into aWallClock
- Add
:use_secondsand:include_meridiemoptions toWallClock#to_s
WallClock#newnow works when creating a time representing 12:00PM- Units are now properly zero-padded in
WallClock#to_s
- Add
WallClock#to_i
- Apply some optimizations to
RelativeTime
- Add
WallClockclass to represent "wall-clock" times (times without dates) - Add formatting options to
RelativeTime#to_s - Add
Date#at
- Implement
#==(equality comparisons) toRelativeTime
- Add
#since,#until, and#betweentoTime, to compare times and returnRelativeTimes - Add
#yesterdayand#tomorrowtoDate
- Initial release, which includes the
RelativeTimeclass as well as#seconds,#minutes, etc. helpers to createRelativeTimes fromFixnums