partial-date 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
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.
@@ -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 1 and 12"
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 1 and 12"
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 year and month must be set before a day" if year == 0 && month == 0
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 1 and 31"
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 1 and 31"
184
+ raise PartialDateError, "Day must be an integer between 0 and 31"
185
185
  end
186
186
  end
187
187
 
@@ -1,4 +1,4 @@
1
1
  module PartialDate
2
2
  # partial-date version
3
- VERSION = "1.1.3"
3
+ VERSION = "1.1.4"
4
4
  end
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 1 and 12")
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 1 and 12")
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 1 and 12")
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 year and month must be set before a day")
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 1 and 31")
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 1 and 31")
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 1 and 31")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: partial-date
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: