Sha256: ab9a8a2dc457f5fa4f84127b1e9a89268981b30a3677c6ce0781a8a2066bd417

Contents?: true

Size: 1023 Bytes

Versions: 1

Compression:

Stored size: 1023 Bytes

Contents

require "nordea/bank"
require "nordea/exchange_rates"
require "nordea/version"

# Ruby interface to the Nordea Bank exchange rate data.
module Nordea
  # Parses the datetime format used in the Nordea data.
  #
  # @example
  #   Nordea.parse_time("20150101120056") #=> 2015-01-01 12:00:05 +0200
  #
  # @param [String] the datetime string (YYYYMMDDHHmmSS)
  # @return [Time] the string converted into a Time object
  def self.parse_time(datetime)
     Time.new(datetime[0..3].to_i,
              datetime[4..5].to_i,
              datetime[6..7].to_i,
              datetime[8..9].to_i,
              datetime[10..11].to_i,
              datetime[11..12].to_i,
              "+03:00")
    rescue
      nil
  end

  # Parses the date format used in the Nordea data.
  #
  # @param [String] the date string (YYYYMMDD)
  # @return [Date] the string converted into a Date object
  def self.parse_date(date)
    Date.new(date[0..3].to_i,
             date[4..5].to_i,
             date[6..7].to_i)
    rescue
      nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nordea-1.0.0 lib/nordea.rb