Module: Nordea

Defined in:
lib/nordea.rb,
lib/nordea/bank.rb,
lib/nordea/version.rb,
lib/nordea/exchange_rates.rb

Overview

Version:

  • 2.0.2

Defined Under Namespace

Classes: Bank, ExchangeRates, ServerError

Constant Summary collapse

TZ =

The default timezone, Europe/Helsinki

TZInfo::Timezone.get("Europe/Helsinki")
VERSION =

The gem version

"2.0.2"

Class Method Summary collapse

Class Method Details

.parse_date(date) ⇒ Date

Parses the date format used in the Nordea data.

Parameters:

  • the (String)

    date string (YYYYMMDD)

Returns:

  • (Date)

    the string converted into a Date object



36
37
38
39
40
41
42
# File 'lib/nordea.rb', line 36

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

.parse_time(datetime) ⇒ Time

Parses the datetime format used in the Nordea data.

Examples:

Nordea.parse_time("20150101120056") #=> 2015-01-01 10:00:05 UTC

Parameters:

  • the (String)

    datetime string (YYYYMMDDHHmmSS)

Returns:

  • (Time)

    the string converted into a Time object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nordea.rb', line 18

def self.parse_time(datetime)
  time = Time.utc( 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 )

  # Convert the local time to UTC time.
  TZ.local_to_utc(time)
  rescue
    nil
end