Module: Rounding::TimeExtensions
- Included in:
- ActiveSupport::TimeWithZone, DateTime, Time
- Defined in:
- lib/rounding/time_extensions.rb
Instance Method Summary collapse
- #ceil_in_utc_to(step) ⇒ Object
- #ceil_to(step, around = -utc_offset)) ⇒ Object
- #floor_in_utc_to(step) ⇒ Object
- #floor_to(step, around = -utc_offset)) ⇒ Object
- #round_in_utc_to(step) ⇒ Object
- #round_to(step, around = -utc_offset)) ⇒ Object
Instance Method Details
#ceil_in_utc_to(step) ⇒ Object
30 31 32 |
# File 'lib/rounding/time_extensions.rb', line 30 def ceil_in_utc_to(step) ceil_to(step, 0) end |
#ceil_to(step, around = -utc_offset)) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rounding/time_extensions.rb', line 10 def ceil_to(step, around=-utc_offset) step = step.to_r around = around.to_r rational_self = self.to_r difference = rational_self - rational_self.ceil_to(step, around) self - difference end |
#floor_in_utc_to(step) ⇒ Object
26 27 28 |
# File 'lib/rounding/time_extensions.rb', line 26 def floor_in_utc_to(step) floor_to(step, 0) end |
#floor_to(step, around = -utc_offset)) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/rounding/time_extensions.rb', line 2 def floor_to(step, around=-utc_offset) step = step.to_r around = around.to_r rational_self = self.to_r difference = rational_self - rational_self.floor_to(step, around) self - difference end |
#round_in_utc_to(step) ⇒ Object
34 35 36 |
# File 'lib/rounding/time_extensions.rb', line 34 def round_in_utc_to(step) round_to(step, 0) end |
#round_to(step, around = -utc_offset)) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rounding/time_extensions.rb', line 18 def round_to(step, around=-utc_offset) step = step.to_r around = around.to_r rational_self = self.to_r difference = rational_self - rational_self.round_to(step, around) self - difference end |