Moving date enumeration logic from php to perl because DateTime isn't
stable across versions.