...
 
Commits (5)
## 0.12.0
* Fix `Months#to_seconds` from November (thanks @walterbrebels).
## 0.11.0
* Add support for unary minus operator (thanks @walterbrebels).
......
Copyright (c) 2012-2015 Arnau Siches
Copyright (c) 2012-2018 Arnau Siches
MIT License
......
......@@ -18,7 +18,6 @@ times) standard.
## Build status
[![Build Status](https://secure.travis-ci.org/arnau/ISO8601.png?branch=master)](http://travis-ci.org/arnau/ISO8601/)
[![Dependency Status](https://gemnasium.com/arnau/ISO8601.svg)](https://gemnasium.com/arnau/ISO8601)
[![Gem Version](https://badge.fury.io/rb/iso8601.svg)](http://badge.fury.io/rb/iso8601)
## Supported versions
......
ruby-iso8601 (0.12.0-1) unstable; urgency=medium
* New upstream release.
* Bump Standards_version to 4.2.0, no changes needed.
-- Stefano Rivera <stefanor@debian.org> Wed, 22 Aug 2018 12:40:34 -0700
ruby-iso8601 (0.11.0-1) unstable; urgency=medium
* New upstream release.
......
......@@ -7,7 +7,7 @@ Build-Depends: debhelper (>= 10),
gem2deb,
rake,
ruby-rspec
Standards-Version: 4.1.5
Standards-Version: 4.2.0
Vcs-Git: https://salsa.debian.org/ruby-team/ruby-iso8601.git
Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-iso8601
Homepage: https://github.com/arnau/ISO8601
......
......@@ -76,7 +76,7 @@ module ISO8601
else
month = initial <= 12 ? initial : (initial % 12)
month = 12 if month.zero?
year = base.year + ((base.month + atom) / 12).to_i
year = initial <= 12 ? base.year : base.year + (initial / 12).to_i
end
(::Time.utc(year, month) - ::Time.utc(base.year, base.month)) / atom
......
module ISO8601
##
# The gem version
VERSION = '0.11.0'.freeze
VERSION = '0.12.0'.freeze
end
......@@ -7,6 +7,9 @@ RSpec.describe ISO8601::Duration do
let(:common_february) { ISO8601::DateTime.new('2010-02-01') }
let(:leap_february) { ISO8601::DateTime.new('2000-02-01') }
let(:common_november) { ISO8601::DateTime.new('2010-11-01') }
let(:common_december) { ISO8601::DateTime.new('2010-12-01') }
it "should raise a ISO8601::Errors::UnknownPattern for any unknown pattern" do
expect { ISO8601::Duration.new('') }.to raise_error(ISO8601::Errors::UnknownPattern)
expect { ISO8601::Duration.new('P') }.to raise_error(ISO8601::Errors::UnknownPattern)
......@@ -120,6 +123,10 @@ RSpec.describe ISO8601::Duration do
expect(ISO8601::Duration.new('P1M').to_seconds(common_year)).to eq(2678400)
expect(ISO8601::Duration.new('P19M').to_seconds(ISO8601::DateTime.new('2012-05-01'))).to eq(Time.utc(2014, 12) - Time.utc(2012, 5))
expect(ISO8601::Duration.new('P14M').to_seconds(common_year)).to eq(Time.utc(2011, 3) - Time.utc(2010, 1))
expect(ISO8601::Duration.new('P1M').to_seconds(common_november)).to eq(Time.utc(2010, 12) - Time.utc(2010, 11))
expect(ISO8601::Duration.new('P1M').to_seconds(common_december)).to eq(Time.utc(2011, 1) - Time.utc(2010, 12))
expect(ISO8601::Duration.new('P2M').to_seconds(common_november)).to eq(Time.utc(2011, 1) - Time.utc(2010, 11))
expect(ISO8601::Duration.new('P3M').to_seconds(common_november)).to eq(Time.utc(2011, 2) - Time.utc(2010, 11))
end
it "should return the seconds of a P[n]M duration in a leap year" do
......
......@@ -7,6 +7,8 @@ RSpec.describe ISO8601::Months do
let(:common_february) { ISO8601::DateTime.new('2010-02-01') }
let(:leap_february) { ISO8601::DateTime.new('2000-02-01') }
let(:common_november) { ISO8601::DateTime.new('2017-11-01') }
let(:common_december) { ISO8601::DateTime.new('2017-12-01') }
let(:leap_december) { ISO8601::DateTime.new('2000-12-01') }
......@@ -62,6 +64,9 @@ RSpec.describe ISO8601::Months do
expect(ISO8601::Months.new(1).to_seconds(common_year)).to eq(2678400)
expect(ISO8601::Months.new(0).to_seconds(common_year)).to eq(0)
expect(ISO8601::Months.new(0).to_seconds(common_december)).to eq(0)
expect(ISO8601::Months.new(2).to_seconds(common_november)).to eq(5270400)
expect(ISO8601::Months.new(1).to_seconds(common_november)).to eq(2592000)
expect(ISO8601::Months.new(0).to_seconds(common_november)).to eq(0)
end
it "should return the amount of seconds for a leap year" do
......