lib/redistat/finder/date_set.rb in redistat-0.0.6 vs lib/redistat/finder/date_set.rb in redistat-0.0.7
- old
+ new
@@ -40,11 +40,11 @@
def find_start_keys_for(unit, start_date, end_date, lowest_depth = false)
return find_start_year_for(start_date, end_date, lowest_depth) if unit == :year
index = Date::DEPTHS.index(unit)
nunit = Date::DEPTHS[(index > 0) ? index-1 : index]
- if start_date < start_date.round(nunit) || start_date.next(nunit).beginning_of(nunit) > end_date.beginning_of(nunit)
+ if start_date < start_date.beginning_of_closest(nunit) || start_date.next(nunit).beginning_of(nunit) > end_date.beginning_of(nunit)
add = []
start_date.beginning_of_each(unit, :include_start => lowest_depth).until(start_date.end_of(nunit)) do |t|
add << t.to_rs.to_s(unit) if t < end_date.beginning_of(unit)
end
{ :add => add, :rem => [] }
@@ -57,10 +57,10 @@
def find_end_keys_for(unit, start_date, end_date, lowest_depth = false)
return find_end_year_for(start_date, end_date, lowest_depth) if unit == :year
index = Date::DEPTHS.index(unit)
nunit = Date::DEPTHS[(index > 0) ? index-1 : index]
has_nunit = end_date.prev(nunit).beginning_of(nunit) >= start_date.beginning_of(nunit)
- nearest_nunit = end_date.round(nunit)
+ nearest_nunit = end_date.beginning_of_closest(nunit)
if end_date >= nearest_nunit && has_nunit
add = []
end_date.beginning_of(nunit).beginning_of_each(unit, :include_start => true, :include_end => lowest_depth).until(end_date) do |t|
add << t.to_rs.to_s(unit) if t > start_date.beginning_of(unit)
end
\ No newline at end of file