speaking as a non-coder, it's not obvious to me why counter is 0 at 1st day of new year. year should not matter at all if it's purely a X (28 in this case, or 7 for taxes, or food or whatever) day cycle.
It is because we do not actually "count" - i.e. we don't increment a variable by +1 every day. What we do is look at the day-of-the-year and divide that by our cycle period.