Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes the problems with Time parsing on 1.8.7.

  • Loading branch information...
commit 2f9ca6aa7886dc400084f7ca2a637277a331ae37 1 parent c89802f
@matiaskorhonen authored
View
4 .travis.yml
@@ -1,5 +1,9 @@
script: "bundle exec rake spec"
rvm:
+ - 1.8.7
- 1.9.2
+ - jruby
+ - rbx
+ - ree
notifications:
disable: true
View
22 lib/nordea.rb
@@ -1,24 +1,30 @@
require "nordea/bank"
require "nordea/exchange_rates"
require "nordea/version"
+require "tzinfo"
# Ruby interface to the Nordea Bank exchange rate data.
module Nordea
+ # The default timezone, Europe/Helsinki
+ TZ = TZInfo::Timezone.get("Europe/Helsinki")
+
# Parses the datetime format used in the Nordea data.
#
# @example
- # Nordea.parse_time("20150101120056") #=> 2015-01-01 12:00:05 +0200
+ # Nordea.parse_time("20150101120056") #=> 2015-01-01 10:00:05 UTC
#
# @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")
+ 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
View
13 nordea.gemspec
@@ -14,16 +14,17 @@ Gem::Specification.new do |s|
s.rubyforge_project = "nordea"
s.add_dependency "money", "~> 3.7.1"
+ s.add_dependency "tzinfo", "~> 0.3.28"
- s.add_development_dependency "yard"
- s.add_development_dependency "rspec"
- s.add_development_dependency "webmock"
s.add_development_dependency "awesome_print"
- s.add_development_dependency "simplecov"
+ s.add_development_dependency "bundler", "~> 1.0.15"
s.add_development_dependency "rake", "~> 0.9.2"
+ s.add_development_dependency "rspec", "~> 2.6.0"
+ s.add_development_dependency "simplecov"
+ s.add_development_dependency "webmock"
+ s.add_development_dependency "yard"
s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_paths = ["lib"]
end
View
BIN  spec/support/sample_currencies.marshal
Binary file not shown

0 comments on commit 2f9ca6a

Please sign in to comment.
Something went wrong with that request. Please try again.