| Class | IceCube::Occurrence |
| In: |
lib/ice_cube/occurrence.rb
|
| Parent: | SimpleDelegator |
Wraps start_time and end_time in a single concept concerning the duration. This delegates to the enclosed start_time so it behaves like a normal Time in almost all situations, however:
Without ActiveSupport, it‘s necessary to cast the occurrence using +to_time+ before doing arithmetic, else Time will try to subtract it using +to_i+ and return a new time instead.
Time.now - Occurrence.new(start_time) # => 1970-01-01 01:00:00
Time.now - Occurrence.new(start_time).to_time # => 3600
When ActiveSupport::Time core extensions are loaded, it‘s possible to subtract an Occurrence object directly from a Time to get the difference:
Time.now - Occurrence.new(start_time) # => 3600
| start_time | -> | first |
| end_time | -> | last |
| end_time | [R] | |
| start_time | [R] |
Shows both the start and end time if there is a duration. Optional format argument (e.g. :long, :short) supports Rails time formats and is only used when ActiveSupport is available.