Module: Timerage

Defined in:
lib/timerage.rb,
lib/timerage/version.rb,
lib/timerage/time_interval.rb

Defined Under Namespace

Classes: TimeInterval

Constant Summary collapse

VERSION =
"2.3.0"

Class Method Summary collapse

Class Method Details

.Interval(begin_or_end_time, end_time_or_duration, exclude_end: true) ⇒ Object

Returns a new TimeInterval from a time and duration or two times.

signature:

Interval(begin_time, end_time, exclude_end: true)
Interval(begin_or_end_time, duration, exclude_end: true)


24
25
26
27
28
29
30
# File 'lib/timerage.rb', line 24

def self.Interval(begin_or_end_time, end_time_or_duration, exclude_end: true)
  if end_time_or_duration.respond_to?(:since)
    TimeInterval.from_time_and_duration(begin_or_end_time, end_time_or_duration, exclude_end: exclude_end)
  else
    TimeInterval.new(begin_or_end_time, end_time_or_duration, exclude_end)
  end
end

.parse_iso8601(str, exclusive_end: true) ⇒ Object

Returns a Time or Timerage::TimeInterval representation of the iso8601 str.

Currently this only supports ‘<begin>/<end>` style time intervals.



13
14
15
16
17
# File 'lib/timerage.rb', line 13

def self.parse_iso8601(str, exclusive_end: true)
  TimeInterval.iso8601(str, exclusive_end: exclusive_end)
rescue ArgumentError
  Time.iso8601(str)
end