Sha256: 5b6aa5822dd7e80bd2f8aba6a046654a0c3620d001f23dd6df36a1bc1d483115

Contents?: true

Size: 438 Bytes

Versions: 6

Compression:

Stored size: 438 Bytes

Contents

module Reservation
  module TimeOffset
    def parse_time_offset hhmm
      orig = hhmm
      hhmm = hhmm.gsub /[^\d]/, ""
      hhmm = "0#{hhmm}00" if hhmm.length == 1
      hhmm = "#{hhmm}00" if hhmm.length == 2
      hhmm = "0#{hhmm}" if hhmm.length == 3
      raise "Can't parse #{orig.inspect}" unless hhmm.match(/^\d\d\d\d$/)

      hh = hhmm[0,2].to_i
      mm = hhmm[2,4].to_i

      { :hour => hh, :min => mm }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
reservation-0.1.0 lib/reservation/time_offset.rb
reservation-0.0.6 lib/reservation/time_offset.rb
reservation-0.0.5 lib/reservation/time_offset.rb
reservation-0.0.4 lib/reservation/time_offset.rb
reservation-0.0.3 lib/reservation/time_offset.rb
reservation-0.0.2 lib/reservation/time_offset.rb