diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-05-01 18:09:49 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-05-01 18:09:49 +0100 |
commit | fd85e6a1d697be8652eb6fdb278969b4afc4923c (patch) | |
tree | 690f191d1536937d3f9939a574d8f54597dc8ec4 /lib/date_quarter.rb | |
parent | 7956b0398457f12d645dac9c1be65b0bd29a84dd (diff) | |
parent | 4d04209d29b76c997e5238d8546d7eb17ee2bd53 (diff) |
Merge branch 'rails-3-develop' of ssh://git.mysociety.org/data/git/public/alaveteli into rails-3-develop
Diffstat (limited to 'lib/date_quarter.rb')
-rw-r--r-- | lib/date_quarter.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/date_quarter.rb b/lib/date_quarter.rb new file mode 100644 index 000000000..ac159b420 --- /dev/null +++ b/lib/date_quarter.rb @@ -0,0 +1,22 @@ +module DateQuarter + extend self + + def quarters_between(start_at, finish_at) + results = [] + + quarter_start = start_at.beginning_of_quarter + quarter_end = start_at.end_of_quarter + + while quarter_end <= finish_at.end_of_quarter do + # Collect these + results << [quarter_start, quarter_end] + + # Update dates + quarter_start = quarter_end + 1.second + quarter_end = quarter_start.end_of_quarter + end + + results + end + +end |