Class: Time

Inherits:
Object show all
Defined in:
lib/coaster/core_ext/time.rb

Instance Method Summary collapse

Instance Method Details

#beginning_of_range(timezone = ::Time.zone) ⇒ Object



8
9
10
# File 'lib/coaster/core_ext/time.rb', line 8

def beginning_of_range(timezone = ::Time.zone)
  to_time_range(timezone).begin
end

#end_of_range(timezone = ::Time.zone) ⇒ Object



12
13
14
# File 'lib/coaster/core_ext/time.rb', line 12

def end_of_range(timezone = ::Time.zone)
  to_time_range(timezone).end
end

#to_time_range(timezone = ::Time.zone) ⇒ Object



2
3
4
5
6
# File 'lib/coaster/core_ext/time.rb', line 2

def to_time_range(timezone = ::Time.zone)
  timezone = ActiveSupport::TimeZone[timezone] if timezone.is_a?(String)
  s = self.in_time_zone(timezone).change(usec: 0)
  s...(s + 1.second)
end