File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,8 @@ Changes:
101101 * Deprecate ` Enumerable#mash ` (use ` Enumerable#graph ` instead).
102102 * Deprecate ` Enumerable#uniq_by ` (use ` Enumerable#uniq(&block) ` , Ruby 1.9.2+).
103103 * Redefine ` String#lchomp ` / ` #lchomp! ` as aliases for ` delete_prefix ` / ` delete_prefix! ` .
104+ * Rename ` Time#trunc ` to ` Time#floor_to ` (parallels ` Time#round_to ` ; avoids confusion
105+ with Ruby's ` Time#floor ` which takes sub-second digit precision). ` trunc ` deprecated.
104106 * Fix dead requires for removed ` kernel/singleton_class ` in Proc and Kernel.
105107 * Remove misplaced ` applique/file_helpers ` from core (test infrastructure).
106108 * Drop unused ` test_files ` directive from gemspec. (PR #301 )
Original file line number Diff line number Diff line change 11class Time
22
3- # Truncate time at give range (in seconds).
3+ # Truncate time to a given interval in seconds.
4+ # Unlike Ruby's Time#floor which takes sub-second digit precision,
5+ # this takes an interval in seconds.
46 #
57 # t = Time.now
6- # t = t.trunc (60*60)
8+ # t = t.floor_to (60*60)
79 # t.min #=> 0
810 # t.sec #=> 0
911 #
10- def trunc ( amount )
11- self - ( self . to_i % amount )
12+ def floor_to ( seconds )
13+ self - ( self . to_i % seconds )
1214 end
1315
14- end
16+ # @deprecated Use Time#floor_to instead.
17+ def trunc ( seconds )
18+ warn "Time#trunc is deprecated. Use Time#floor_to instead." , uplevel : 1
19+ floor_to ( seconds )
20+ end
1521
22+ end
You can’t perform that action at this time.
0 commit comments