lib/by_star/between.rb in by_star-2.2.0.rc1 vs lib/by_star/between.rb in by_star-2.2.0
- old
+ new
@@ -12,22 +12,10 @@
time = ByStar::Normalization.time(time)
between_times(time.beginning_of_day, time.end_of_day, options)
end
end
- def today(options={})
- by_day(Time.zone.now, options)
- end
-
- def yesterday(options={})
- by_day(Time.zone.now.yesterday, options)
- end
-
- def tomorrow(options={})
- by_day(Time.zone.now.tomorrow, options)
- end
-
def by_week(*args)
with_by_star_options(*args) do |time, options|
time = ByStar::Normalization.week(time, options)
start_day = Array(options[:start_day])
between_times(time.beginning_of_week(*start_day), time.end_of_week(*start_day), options)
@@ -73,8 +61,60 @@
def by_year(*args)
with_by_star_options(*args) do |time, options|
time = ByStar::Normalization.year(time, options)
between_times(time.beginning_of_year, time.end_of_year, options)
end
+ end
+
+ def today(options={})
+ by_day(Time.zone.now, options)
+ end
+
+ def yesterday(options={})
+ by_day(Time.zone.now.yesterday, options)
+ end
+
+ def tomorrow(options={})
+ by_day(Time.zone.now.tomorrow, options)
+ end
+
+ def past_day(options={})
+ between_times(Time.zone.now - 1.day, Time.zone.now, options)
+ end
+
+ def past_week(options={})
+ between_times(Time.zone.now - 1.week, Time.zone.now, options)
+ end
+
+ def past_fortnight(options={})
+ between_times(Time.zone.now - 2.weeks, Time.zone.now, options)
+ end
+
+ def past_month(options={})
+ between_times(Time.zone.now - 1.month, Time.zone.now, options)
+ end
+
+ def past_year(options={})
+ between_times(Time.zone.now - 1.year, Time.zone.now, options)
+ end
+
+ def next_day(options={})
+ between_times(Time.zone.now, Time.zone.now + 1.day, options)
+ end
+
+ def next_week(options={})
+ between_times(Time.zone.now, Time.zone.now + 1.week, options)
+ end
+
+ def next_fortnight(options={})
+ between_times(Time.zone.now, Time.zone.now + 2.weeks, options)
+ end
+
+ def next_month(options={})
+ between_times(Time.zone.now, Time.zone.now + 1.month, options)
+ end
+
+ def next_year(options={})
+ between_times(Time.zone.now, Time.zone.now + 1.year, options)
end
end
end