Module: ByStar::Between
- Included in:
- Base
- Defined in:
- lib/by_star/between.rb
Instance Method Summary collapse
- #between_times(start, finish, options = {}) ⇒ Object
- #by_calendar_month(*args) ⇒ Object
- #by_day(*args) ⇒ Object
- #by_fortnight(*args) ⇒ Object
- #by_month(*args) ⇒ Object
- #by_quarter(*args) ⇒ Object
- #by_week(*args) ⇒ Object
- #by_weekend(*args) ⇒ Object
- #by_year(*args) ⇒ Object
- #next_day(options = {}) ⇒ Object
- #next_fortnight(options = {}) ⇒ Object
- #next_month(options = {}) ⇒ Object
- #next_week(options = {}) ⇒ Object
- #next_year(options = {}) ⇒ Object
- #past_day(options = {}) ⇒ Object
- #past_fortnight(options = {}) ⇒ Object
- #past_month(options = {}) ⇒ Object
- #past_week(options = {}) ⇒ Object
- #past_year(options = {}) ⇒ Object
- #today(options = {}) ⇒ Object
- #tomorrow(options = {}) ⇒ Object
- #yesterday(options = {}) ⇒ Object
Instance Method Details
#between_times(start, finish, options = {}) ⇒ Object
5 6 7 8 |
# File 'lib/by_star/between.rb', line 5 def between_times(start, finish, ={}) offset = by_star_offset() between_times_query(start + offset, finish + offset, ) end |
#by_calendar_month(*args) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/by_star/between.rb', line 46 def by_calendar_month(*args) (*args) do |time, | time = ByStar::Normalization.month(time, ) start_day = Array([:start_day]) between_times(time.beginning_of_calendar_month(*start_day), time.end_of_calendar_month(*start_day), ) end end |
#by_day(*args) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/by_star/between.rb', line 10 def by_day(*args) (*args) do |time, | time = ByStar::Normalization.time(time) between_times(time.beginning_of_day, time.end_of_day, ) end end |
#by_fortnight(*args) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/by_star/between.rb', line 32 def by_fortnight(*args) (*args) do |time, | time = ByStar::Normalization.fortnight(time, ) between_times(time.beginning_of_fortnight, time.end_of_fortnight, ) end end |
#by_month(*args) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/by_star/between.rb', line 39 def by_month(*args) (*args) do |time, | time = ByStar::Normalization.month(time, ) between_times(time.beginning_of_month, time.end_of_month, ) end end |
#by_quarter(*args) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/by_star/between.rb', line 54 def by_quarter(*args) (*args) do |time, | time = ByStar::Normalization.quarter(time, ) between_times(time.beginning_of_quarter, time.end_of_quarter, ) end end |
#by_week(*args) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/by_star/between.rb', line 17 def by_week(*args) (*args) do |time, | time = ByStar::Normalization.week(time, ) start_day = Array([:start_day]) between_times(time.beginning_of_week(*start_day), time.end_of_week(*start_day), ) end end |
#by_weekend(*args) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/by_star/between.rb', line 25 def by_weekend(*args) (*args) do |time, | time = ByStar::Normalization.week(time, ) between_times(time.beginning_of_weekend, time.end_of_weekend, ) end end |
#by_year(*args) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/by_star/between.rb', line 61 def by_year(*args) (*args) do |time, | time = ByStar::Normalization.year(time, ) between_times(time.beginning_of_year, time.end_of_year, ) end end |
#next_day(options = {}) ⇒ Object
100 101 102 |
# File 'lib/by_star/between.rb', line 100 def next_day(={}) between_times(Time.zone.now, Time.zone.now + 1.day, ) end |
#next_fortnight(options = {}) ⇒ Object
108 109 110 |
# File 'lib/by_star/between.rb', line 108 def next_fortnight(={}) between_times(Time.zone.now, Time.zone.now + 2.weeks, ) end |
#next_month(options = {}) ⇒ Object
112 113 114 |
# File 'lib/by_star/between.rb', line 112 def next_month(={}) between_times(Time.zone.now, Time.zone.now + 1.month, ) end |
#next_week(options = {}) ⇒ Object
104 105 106 |
# File 'lib/by_star/between.rb', line 104 def next_week(={}) between_times(Time.zone.now, Time.zone.now + 1.week, ) end |
#next_year(options = {}) ⇒ Object
116 117 118 |
# File 'lib/by_star/between.rb', line 116 def next_year(={}) between_times(Time.zone.now, Time.zone.now + 1.year, ) end |
#past_day(options = {}) ⇒ Object
80 81 82 |
# File 'lib/by_star/between.rb', line 80 def past_day(={}) between_times(Time.zone.now - 1.day, Time.zone.now, ) end |
#past_fortnight(options = {}) ⇒ Object
88 89 90 |
# File 'lib/by_star/between.rb', line 88 def past_fortnight(={}) between_times(Time.zone.now - 2.weeks, Time.zone.now, ) end |
#past_month(options = {}) ⇒ Object
92 93 94 |
# File 'lib/by_star/between.rb', line 92 def past_month(={}) between_times(Time.zone.now - 1.month, Time.zone.now, ) end |
#past_week(options = {}) ⇒ Object
84 85 86 |
# File 'lib/by_star/between.rb', line 84 def past_week(={}) between_times(Time.zone.now - 1.week, Time.zone.now, ) end |
#past_year(options = {}) ⇒ Object
96 97 98 |
# File 'lib/by_star/between.rb', line 96 def past_year(={}) between_times(Time.zone.now - 1.year, Time.zone.now, ) end |
#today(options = {}) ⇒ Object
68 69 70 |
# File 'lib/by_star/between.rb', line 68 def today(={}) by_day(Time.zone.now, ) end |
#tomorrow(options = {}) ⇒ Object
76 77 78 |
# File 'lib/by_star/between.rb', line 76 def tomorrow(={}) by_day(Time.zone.now.tomorrow, ) end |
#yesterday(options = {}) ⇒ Object
72 73 74 |
# File 'lib/by_star/between.rb', line 72 def yesterday(={}) by_day(Time.zone.now.yesterday, ) end |