Sha256: 53f389894e2f0d908e60b25cb04508bc4e7d432b7778dbc3eeb343dbd7102e0d

Contents?: true

Size: 785 Bytes

Versions: 4

Compression:

Stored size: 785 Bytes

Contents

module XeroGateway
  module Dates
    def self.included(base)
      base.extend(ClassMethods)
    end
    
    module ClassMethods
      def format_date(time)
        return time.strftime("%Y-%m-%d")
      end
      
      def format_date_time(time)
        return time.strftime("%Y%m%d%H%M%S")
      end
      
      def parse_date(time)
        Date.civil(time[0..3].to_i, time[5..6].to_i, time[8..9].to_i)
      end
      
      def parse_date_time(time)
        Time.local(time[0..3].to_i, time[5..6].to_i, time[8..9].to_i, time[11..12].to_i, time[14..15].to_i, time[17..18].to_i)
      end

      def parse_date_time_utc(time)
        Time.utc(time[0..3].to_i, time[5..6].to_i, time[8..9].to_i, time[11..12].to_i, time[14..15].to_i, time[17..18].to_i)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xero_gateway-2.6.0 lib/xero_gateway/dates.rb
xero_gateway-2.5.0 lib/xero_gateway/dates.rb
xero_gateway-2.4.0 lib/xero_gateway/dates.rb
xero_gateway-2.3.0 lib/xero_gateway/dates.rb