Cleanup: reuse encodeDate, add enumeration to remove magic numbers