refactor formatDate function and create test
Merge pull request #476 from lunika/date

refactor formatDate function and create test