refactor date_format method