partial-date 1.1.3 → 1.1.4
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 +5 -0
- data/lib/partial-date/date.rb +5 -5
- data/lib/partial-date/version.rb +1 -1
- data/spec/date_spec.rb +7 -7
- metadata +1 -1
data/ChangeLog.textile
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
h3. 1.1.4 / 2012-05-29
|
2
|
+
|
3
|
+
* Changed error messages for month and day to 0 - 12 and 0 - 31 respectively (since zero values are allowed).
|
4
|
+
* Changed day validation logic to only check for the presence of month (not year and month - since a year has to be set before a month and is checked there).
|
5
|
+
|
1
6
|
h3. 1.1.3 / 2012-05-28
|
2
7
|
|
3
8
|
* Bugfix: Fixed ZERO_DAY_MASK - which contained an extra bit, and was zeroing month when a day was set.
|
data/lib/partial-date/date.rb
CHANGED
@@ -139,7 +139,7 @@ module PartialDate
|
|
139
139
|
if value =~ /\A\d{1,2}\z/
|
140
140
|
value = value.to_i
|
141
141
|
else
|
142
|
-
raise PartialDateError, "Month must be a valid one or two digit string or integer between
|
142
|
+
raise PartialDateError, "Month must be a valid one or two digit string or integer between 0 and 12"
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
@@ -147,7 +147,7 @@ module PartialDate
|
|
147
147
|
@bits = Bits.set_month(@bits, value)
|
148
148
|
@bits = Bits.set_day(@bits, 0) if value == 0
|
149
149
|
else
|
150
|
-
raise PartialDateError, "Month must an be integer between
|
150
|
+
raise PartialDateError, "Month must an be integer between 0 and 12"
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -161,7 +161,7 @@ module PartialDate
|
|
161
161
|
# nil and empty strings are allowed.
|
162
162
|
def day=(value)
|
163
163
|
|
164
|
-
raise PartialDateError, "A
|
164
|
+
raise PartialDateError, "A month must be set before a day" if month == 0
|
165
165
|
|
166
166
|
value = 0 if value.nil?
|
167
167
|
|
@@ -169,7 +169,7 @@ module PartialDate
|
|
169
169
|
if value =~ /\A\d{1,2}\z/
|
170
170
|
value = value.to_i
|
171
171
|
else
|
172
|
-
raise PartialDateError, "Day must be a valid one or two digit string or integer between
|
172
|
+
raise PartialDateError, "Day must be a valid one or two digit string or integer between 0 and 31"
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
@@ -181,7 +181,7 @@ module PartialDate
|
|
181
181
|
raise PartialDateError, "Day must be a valid day for the given month"
|
182
182
|
end
|
183
183
|
else
|
184
|
-
raise PartialDateError, "Day must be an integer between
|
184
|
+
raise PartialDateError, "Day must be an integer between 0 and 31"
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
data/lib/partial-date/version.rb
CHANGED
data/spec/date_spec.rb
CHANGED
@@ -102,15 +102,15 @@ describe PartialDate::Date do
|
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should raise an error if month is set to an invalid string" do
|
105
|
-
expect {date.month = "AB"}.to raise_error(PartialDate::PartialDateError, "Month must be a valid one or two digit string or integer between
|
105
|
+
expect {date.month = "AB"}.to raise_error(PartialDate::PartialDateError, "Month must be a valid one or two digit string or integer between 0 and 12")
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should raise an error if month is set to a value greater than 12" do
|
109
|
-
expect {date.month = 13}.to raise_error(PartialDate::PartialDateError, "Month must an be integer between
|
109
|
+
expect {date.month = 13}.to raise_error(PartialDate::PartialDateError, "Month must an be integer between 0 and 12")
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should raise an error if month is set to a value less than zero" do
|
113
|
-
expect {date.month = -1}.to raise_error(PartialDate::PartialDateError, "Month must an be integer between
|
113
|
+
expect {date.month = -1}.to raise_error(PartialDate::PartialDateError, "Month must an be integer between 0 and 12")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should allow the month to be set to zero" do
|
@@ -134,19 +134,19 @@ describe PartialDate::Date do
|
|
134
134
|
|
135
135
|
it "should raise an error if a day is set before a year and month" do
|
136
136
|
no_month = PartialDate::Date.new
|
137
|
-
expect {no_month.day = 10}.to raise_error(PartialDate::PartialDateError, "A
|
137
|
+
expect {no_month.day = 10}.to raise_error(PartialDate::PartialDateError, "A month must be set before a day")
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should raise an error if day is set to an invalid string" do
|
141
|
-
expect {date.day = "AB"}.to raise_error(PartialDate::PartialDateError, "Day must be a valid one or two digit string or integer between
|
141
|
+
expect {date.day = "AB"}.to raise_error(PartialDate::PartialDateError, "Day must be a valid one or two digit string or integer between 0 and 31")
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should raise an error if day is set to a value less than zero" do
|
145
|
-
expect {date.day = -1}.to raise_error(PartialDate::PartialDateError, "Day must be an integer between
|
145
|
+
expect {date.day = -1}.to raise_error(PartialDate::PartialDateError, "Day must be an integer between 0 and 31")
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should raise an error if day is set to a value greater than 31" do
|
149
|
-
expect {date.day = 32}.to raise_error(PartialDate::PartialDateError, "Day must be an integer between
|
149
|
+
expect {date.day = 32}.to raise_error(PartialDate::PartialDateError, "Day must be an integer between 0 and 31")
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should raise an error if the day is an invalid day for the given month" do
|