Sha256: 40a4046b7d0d8f01b15a9528fa7c15a49055f4ab4cf980e7c0c9e6e375aac0e9

Contents?: true

Size: 950 Bytes

Versions: 23

Compression:

Stored size: 950 Bytes

Contents

module Adyen
  module Formatter
    module DateTime
      # Returns a valid Adyen string representation for a date
      def self.fmt_date(date)
        case date
        when Date, DateTime, Time
          date.strftime('%Y-%m-%d')
        else
          raise "Invalid date notation: #{date.inspect}!" unless /^\d{4}-\d{2}-\d{2}$/ =~ date
          date
        end
      end

      # Returns a valid Adyen string representation for a timestamp
      def self.fmt_time(time)
        case time
        when Date, DateTime, Time
          time.strftime('%Y-%m-%dT%H:%M:%SZ')
        else
          raise "Invalid timestamp notation: #{time.inspect}!" unless /^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z$/ =~ time
          time
        end
      end
    end

    module Price
      def self.in_cents(price)
        ((price * 100).round).to_i
      end

      def self.from_cents(price)
        BigDecimal.new(price.to_s) / 100
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
wvanbergen-adyen-0.1.5 lib/adyen/formatter.rb
fingertips-adyen-0.3.8.20101015 lib/adyen/formatter.rb
fingertips-adyen-0.3.8.20101007 lib/adyen/formatter.rb
fingertips-adyen-0.3.8.20100930.2 lib/adyen/formatter.rb
fingertips-adyen-0.3.8.20100930 lib/adyen/formatter.rb
fingertips-adyen-0.3.8.20100929 lib/adyen/formatter.rb
fingertips-adyen-0.3.8.20100924 lib/adyen/formatter.rb
adyen-0.3.8 lib/adyen/formatter.rb
fingertips-adyen-0.3.7.20100917 lib/adyen/formatter.rb
adyen-0.3.7 lib/adyen/formatter.rb
adyen-0.3.6 lib/adyen/formatter.rb
adyen-0.3.5 lib/adyen/formatter.rb
adyen-0.3.4 lib/adyen/formatter.rb
adyen-0.3.3 lib/adyen/formatter.rb
adyen-0.3.2 lib/adyen/formatter.rb
adyen-0.3.0 lib/adyen/formatter.rb
adyen-0.2.3 lib/adyen/formatter.rb
adyen-0.2.2 lib/adyen/formatter.rb
floorplanner-adyen-0.2.2 lib/adyen/formatter.rb
adyen-0.2.1 lib/adyen/formatter.rb