Sha256: f716144d279b159223672bf0da613f6de3ddb6b40ff645eaeea084d80ff061ea

Contents?: true

Size: 763 Bytes

Versions: 9

Compression:

Stored size: 763 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
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
adyen-1.5.0 lib/adyen/formatter.rb
adyen-1.4.1 lib/adyen/formatter.rb
adyen-1.4.0 lib/adyen/formatter.rb
adyen-1.3.2 lib/adyen/formatter.rb
adyen-1.3.1 lib/adyen/formatter.rb
adyen-1.3.0 lib/adyen/formatter.rb
adyen-1.2.0 lib/adyen/formatter.rb
adyen-1.1.0 lib/adyen/formatter.rb
adyen-1.0.0 lib/adyen/formatter.rb