- 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_s
to 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_s
is the new:min_long
format, which is similar to the:long
format except it excludes weeks.
- The default format of
- Timerizer now only supports Ruby 2.0+!
RelativeTime
is nowTimerizer:Duration
. If you used the explicitRelativeTime
constructor, you will need to update your code accordingly when updating to Timerizer 0.3.0+!WallClock
has moved into theTimerizer
module, so if you were usingWallClock
, all references will need to be updated toTimerizer::WallClock
!- The two-argument constructor of
RelativeTime
has been removed (i.e:RelativeTime.new(5, :minutes)
). The equivalent withDuration
now uses a hash:Timerizer::Duration.new(minutes: 5)
RelativeTime#average
,RelativeTime#average!
,RelativeTime#unaverage
andRelativeTime#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
/#unaverage
do 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_unit
method (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_seconds
andunits_in_months
class methods fromRelativeTime
have been removed. See the newDuration::UNITS
andDuration::UNIT_ALIASES
constants for a replacement. - Comparisons on
Duration
differ from the former comparisons onRelativeTime
. Durations are normalized before comparing, so some equality tests may now returntrue
(for example,30.days == 1.month
now returns true due to normalization).
- Timerizer now depends on Ruby 2.0+
RelativeTime
is nowDuration
Duration
andWallClock
have been moved into the newTimerizer
moduleDuration#new
has been reworked. It now takes a single hash mapping units to unit quantities. Unlike the old constructor, it takes arbitrary units now, not just:seconds
and:months
.Duration#to_s
now uses"mo"
as a shorthand instead of"mn"
.Duration#to_s
will now never return decades, centuries, or millennia in the default string formats. The changes toDuration#to_s
now accept user-defined formatters, so clients can restore the old behavior with a custom formatter if needed.Duration#to_s
now normalizes and denormalizes before printing. This means30.days.to_s
will be equivalent to1.month.to_s
by default.Duration#==
now normalizes before comparison, so some comparions may be true that were false previously.
- Added
Duration#to_unit
to convert a duration to a specific unit.#to_unit
normalizes the duration, so return values are more intuitive than the old conversion methods (for example,1.month.to_unit(:seconds)
returns30
). - Added
Duration#to_units
to 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#normalize
andDuration#denormalize
to convert between second-based and month-based units. Duration
now implements#<=>
andComparable
to get all comparison operators (instead of just==
and!=
).Duration
now supports representing negative durations of time.Duration
now implements#-@
(unary negation).Duration
now implements#*
(multiplication) and#/
(divison) to multiply and divide by scalar values (currently onlyInteger
s are supported).Duration#to_s
now takes user-defined options. See the docs for more details.
Duration#to_s
no 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#denormalize
andDuration#normalize
should 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 oldRelativeTime
equivalents.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_units
to break down a duration into multiple units, then using#fetch
or#[]
on the resulting hash to get the specific desired unit (that is,relative_time.minutes
is 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
Integer
instead ofFixnum
(for Ruby 2.4+ compatibility)
- Add
WallClock#from_string
to parse a string into aWallClock
- Add
:use_seconds
and:include_meridiem
options toWallClock#to_s
WallClock#new
now 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
WallClock
class 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#between
toTime
, to compare times and returnRelativeTime
s - Add
#yesterday
and#tomorrow
toDate
- Initial release, which includes the
RelativeTime
class as well as#seconds
,#minutes
, etc. helpers to createRelativeTime
s fromFixnum
s