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.
moment("2013-04-01").fquarter();
moment("2013-04-01").fquarter().toString();
moment("2013-01-01").fquarter();
moment("2013-01-01").fquarter().toString();
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.
moment("2013-09-01").fquarter(9);
moment("2013-09-01").fquarter(9).toString();
moment("2013-01-01").fquarter(9);
moment("2013-01-01").fquarter(9).toString();
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.
moment("2013-01-01").fquarter(1);
moment("2013-01-01").fquarter(1).toString();
moment("2013-09-01").fquarter(1);
moment("2013-09-01").fquarter(1).toString();
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.
moment("2013-01-01").fquarter(-3);
moment("2013-01-01").fquarter(-3).toString();
moment("2013-10-01").fquarter(-3);
moment("2013-10-01").fquarter(-3).toString();
Changing the quarter initial
week: {
dow: 1,
doy: 4
},
quarter: "XYZ"