date util and code refactoring