aboutsummaryrefslogtreecommitdiffstats
path: root/lib/date_quarter.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-05-15 17:01:22 +0100
committerLouise Crow <louise.crow@gmail.com>2014-05-15 17:01:22 +0100
commitbb5f95040d377d86629012347343fbf2c7dda016 (patch)
treebe696ec2615b098db34449a982fcb09a68c9c49b /lib/date_quarter.rb
parent6d215fba5cc709c43f12f86da39a643e4be5922b (diff)
parent21027d0d1197e7ac447296ab68a25159860888b2 (diff)
Merge remote-tracking branch 'origin/release/0.18'0.18
Diffstat (limited to 'lib/date_quarter.rb')
-rw-r--r--lib/date_quarter.rb22
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