partial-date 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog.textile +4 -0
- data/lib/partial-date/date.rb +2 -4
- data/lib/partial-date/version.rb +1 -1
- data/spec/date_spec.rb +0 -4
- metadata +1 -1
data/ChangeLog.textile
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
h3. 1.1.6 / 2012-05-30
|
2
2
|
|
3
|
+
* BugFix: Another logical error in to_s - fixed (formatters next).
|
4
|
+
|
5
|
+
h3. 1.1.6 / 2012-05-30
|
6
|
+
|
3
7
|
* Bugfix: Checked that sign is switched off when a postive year is set after a negative year.
|
4
8
|
* Bugfix: Fixed to_s again (before formatters are implemented).
|
5
9
|
|
data/lib/partial-date/date.rb
CHANGED
@@ -133,9 +133,7 @@ module PartialDate
|
|
133
133
|
#
|
134
134
|
# Returns nothing
|
135
135
|
def year=(value)
|
136
|
-
if value.nil?
|
137
|
-
raise YearError, "Year cannot be nil"
|
138
|
-
end
|
136
|
+
value = 0 if value.nil?
|
139
137
|
|
140
138
|
if value.is_a?(String)
|
141
139
|
if value =~ /\A\-?\d{1,7}\z/
|
@@ -228,7 +226,7 @@ module PartialDate
|
|
228
226
|
result = ""
|
229
227
|
if value != 0
|
230
228
|
result = year.to_s.rjust(4, '0') if year != 0
|
231
|
-
result = result + "-" if result.length > 3
|
229
|
+
result = result + "-" if result.length > 3 && month > 0
|
232
230
|
result = result + month.to_s.rjust(2, '0') if month > 0
|
233
231
|
result = result + "-" + day.to_s.rjust(2, '0') if day > 0
|
234
232
|
return result
|
data/lib/partial-date/version.rb
CHANGED
data/spec/date_spec.rb
CHANGED
@@ -83,10 +83,6 @@ describe PartialDate::Date do
|
|
83
83
|
|
84
84
|
|
85
85
|
describe "Year" do
|
86
|
-
it "should raise an error if year is set to nil" do
|
87
|
-
expect {date.year = nil}.to raise_error(PartialDate::YearError)
|
88
|
-
end
|
89
|
-
|
90
86
|
it "should raise an error if year is set to an invalid string" do
|
91
87
|
expect {date.year = "ABCD" }.to raise_error(PartialDate::YearError, "Year must be a valid string or integer from -1048576 to 1048576")
|
92
88
|
end
|