moment-fquarter.js
This plugin provides fiscal quarterly formatting for moment objects.
How to use?
Call the fquarter
method on any moment object. It returns an object by default and can also return a string.
;// {quarter:1, year:2013, nextYear:2014};// Q1 2013/14;// {quarter:4, year:2012, nextYear:2013};// Q4 2012/13
The default fiscal year starting month is April. You can optionally pass in the start month, for example 1 (January) for normal calendar quarters, 7 or 9 (July or September) for academic quarters.
;// {quarter:1, year:2013, nextYear:2014};// Q1 2013/14;// {quarter:2, year:2012, nextYear:2013};// Q2 2012/13
If you use 1 as a starting month, you do not get the additional year as all the quarters fit within the single calendar year.
;// {quarter:1, year:2013, nextYear:null};// Q1 2013;// {quarter:3, year:2013, nextYear:null};// Q3 2013
Backwards fiscal year
Some countries begin their fiscal quarters in the previous year, e.g. US Federal govt. where October 2013 is Q1 2014. You can now use a negative starting month to reflect this.
;// {quarter:2, year:2013, nextYear:2014};// Q2 2013/14;// {quarter:1, year:2014, nextYear:2015};// Q1 2014/15
Changing the quarter initial
week: dow: 1 // Monday is the first day of the week. doy: 4 // The week that contains Jan 4th is the first week of the year.quarter: "XYZ"