Skip to content

Instantly share code, notes, and snippets.

@kjhenner
Created August 4, 2015 23:37
Show Gist options
  • Save kjhenner/0da10e81d35c2f614508 to your computer and use it in GitHub Desktop.
Save kjhenner/0da10e81d35c2f614508 to your computer and use it in GitHub Desktop.
def quarter_range(fiscal_year, quarter)
# Fiscal year n starts in February of year n-1
start_month_offset = 1+((quarter.to_i - 1) * 3)
end_month_offset = start_month_offset + 3
cal_year = Date.parse("#{fiscal_year.to_i-1}-1-1")
{
start: cal_year + start_month_offset.months,
first: cal_year + (start_month_offset+1).months,
second: cal_year + (start_month_offset+2).months,
end: cal_year + end_month_offset.months
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment