refactor of Date.format to reduce complexity.