Module: Booker::Helpers

Defined in:
lib/booker/helpers.rb

Class Method Summary collapse

Class Method Details

.format_date(time, offset = -5) ⇒ Object

Formats a ruby date into the format the Booker wants it in their json API



6
7
8
9
10
# File 'lib/booker/helpers.rb', line 6

def self.format_date time, offset = -5
  return nil unless time

  "/Date(#{(time.in_time_zone(offset)).to_i * 1000})/"
end

.parse_date(time) ⇒ Object

Turn date given by booker api into ruby datetime



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

def self.parse_date time
  return nil unless time

  Time.at( time.scan(/\d+/).first.to_i / 1000 ).to_datetime
end