Consolidate if not previous period checks into a single check.

	Replace a bunch of these: if($offset != 0)
	With one of this: if($offset == 0) $end = now;