[PATCH 1/2] A function for resolving date format and order