groupdate 5.2.0 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d18870af57fc18006c5f176fa3138dfe36a715b16e5a6113f447aee6d3b7468
4
- data.tar.gz: 889870a1a2db8784e28413c6071a784dff66d00b4aaf05a323e70e5d16f09fd8
3
+ metadata.gz: 448e7901aa2448bca591568110960048d18ac0f21faa5c3cae566fc4a6de30c4
4
+ data.tar.gz: ba242e41103ae9d2542ff0509de1f454f58142957f0da190482769a42a152887
5
5
  SHA512:
6
- metadata.gz: 2ae29a1e8d0eb14c4ef904fbe366cb5f7029d9e94429a74f6f70073a880f2910f62d5161d39618808c09dc937185cc79ba233ac3fc7e34f983a8e32d60e0be70
7
- data.tar.gz: 6348f6853cf2015f6777bcc63e1e416a31456a0e779678164992bd6424daca73272bb5fcb12016d1f3c085b4e14e991afa067f4f93354982e7229699f3ea2eab
6
+ metadata.gz: 91b008f8ee0d9ad419ec042ee2f417b621fba09793b223705a2898fe21083a09527885ead3be2d3b8003427473d1f996938098c9bd7139bcb9bffdad2810734c
7
+ data.tar.gz: d4eb493bdf4b7f40eda2733003263bee49e62f9f69fb6239bec118d1768ce0630c21244e819147ca6b5b1556a9b5e125ed69748e2ee69d3c325f31a2740a6ec5
@@ -1,3 +1,8 @@
1
+ ## 5.2.1 (2020-09-09)
2
+
3
+ - Improved error message for invalid ranges
4
+ - Fixed bug with date string ranges
5
+
1
6
  ## 5.2.0 (2020-09-07)
2
7
 
3
8
  - Added warning for non-attribute argument
@@ -194,12 +194,12 @@ module Groupdate
194
194
  if @time_range.end
195
195
  op = @time_range.exclude_end? ? "<" : "<="
196
196
  if @time_range.begin
197
- ["#{column} >= ? AND #{column} #{op} ?", @time_range.first, @time_range.last]
197
+ ["#{column} >= ? AND #{column} #{op} ?", @time_range.begin, @time_range.end]
198
198
  else
199
- ["#{column} #{op} ?", @time_range.last]
199
+ ["#{column} #{op} ?", @time_range.end]
200
200
  end
201
201
  else
202
- ["#{column} >= ?", @time_range.first]
202
+ ["#{column} >= ?", @time_range.begin]
203
203
  end
204
204
  else
205
205
  ["#{column} IS NOT NULL"]
@@ -141,16 +141,35 @@ module Groupdate
141
141
  def time_range
142
142
  @time_range ||= begin
143
143
  time_range = options[:range]
144
- # entire range must be Date if begin or end is Date
145
- if time_range.is_a?(Range) && (time_range.begin.is_a?(Date) || time_range.end.is_a?(Date))
146
- if time_range.begin
147
- start = time_zone.parse(time_range.first.to_s)
144
+
145
+ if time_range.is_a?(Range)
146
+ # check types
147
+ [time_range.begin, time_range.end].each do |v|
148
+ case v
149
+ when nil, Date, Time
150
+ # good
151
+ when String
152
+ # TODO raise error in Groupdate 6
153
+ warn "[groupdate] Range bounds should be Date or Time, not #{v.class.name}. This will raise an error in Groupdate 6"
154
+ break
155
+ else
156
+ raise ArgumentError, "Range bounds should be Date or Time, not #{v.class.name}"
157
+ end
148
158
  end
149
- if time_range.end
150
- last = time_zone.parse(time_range.last.to_s)
151
- last += 1.day unless time_range.exclude_end?
159
+
160
+ start = time_range.begin
161
+ start = start.in_time_zone(time_zone) if start
162
+
163
+ exclude_end = time_range.exclude_end?
164
+
165
+ finish = time_range.end
166
+ finish = finish.in_time_zone(time_zone) if finish
167
+ if time_range.end.is_a?(Date) && !exclude_end
168
+ finish += 1.day
169
+ exclude_end = true
152
170
  end
153
- time_range = Range.new(start, last, true)
171
+
172
+ time_range = Range.new(start, finish, exclude_end)
154
173
  elsif !time_range && options[:last]
155
174
  if period == :quarter
156
175
  step = 3.months
@@ -1,3 +1,3 @@
1
1
  module Groupdate
2
- VERSION = "5.2.0"
2
+ VERSION = "5.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupdate
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-07 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport