More along the same lines:
To implement a quartely magazine, I decided to use the categories as seasons and years — thus I can use all the features of WordPress categories. I’m using category titles like Summer 2002, Spring 2003, and so on.
In home.php I calculate the current quarter and craft that into a category name so I can show posts restricted to the current season. All the other posts are archived by their seasonal names.
Seasonal quarters do not match calendar quarters. Think of fiscal years, which might begin and end on any month. An offset factor is needed to force non-calendar years into four quarters. The basic formula follows in PHP speak.
$last_month_of_the_year = 11;
The end month of your year. Here I’ve used November, the last month of Fall, because I start my new years with Winter — Dec, Jan, and Feb as Q1. You could say your last month is 2 — February — if you wanted to start your new year on March 1st.
$factor = ( 21 – $last_month_of_the_year );
The number here is the offset value. This is from a standard formulary and, since I am not at all mathematically inclined, I simply looked up a formula that calculates the fiscal quarter any given date falls in.
$currentQuarter = ceil((date(‘n’) + $factor) /3) %4 +1 ;
Current month plus factor are divided by 3, rounded up by CEIL, and the special PHP devisor %4 takes only the remainer of division by 4 and drops the rest of the answer. Add 1 to that remainder and you will have the correct current quarter 1 through 4 for the defined fiscal year.
Generally, fiscal years start and end whenever the accountant says they do. I defined my year to match the seasons: Q1 is Winter, Q2 is Spring (March, April, May), Q3 is Summer (June, July, August), and Q4 is Fall (September, October, November). That definition took place on the first line when I set $last_month_of_the_year.