Sha256: ee9784b84dcdaed6e49ab85b580f98090b6e4848b5eb15dad823d19baff1d843

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 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

    module Helpers
      extend ClassMethods
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xero_gateway-2.7.0 lib/xero_gateway/dates.rb