Fixing date calculations in the prefilters

Previously, when calculating the dates for prefilters, we were
calculating a year as just 365 days. This new code uses actual date
functions to account for things like leap years.