def test_parser__ddmmyyyy_slash_delim(self): input_format = "21/01/2020" result = parse_date_str(input_format) self.assertEqual("%d/%m/%Y", result)
def test_parser__iso8601(self): input_format = "2020-02-23T18:47:17+11:00" result = parse_date_str(input_format) self.assertEqual("%Y-%m-%dT%H:%M:%S%Z", result)
def test_parser__YYYY_dash_mm_dash_dd(self): input_format = "2020-02-21" result = parse_date_str(input_format) self.assertEqual("%Y-%m-%d", result)
def test_parser__hhmmsspm_colon_delim_24hr(self): input_format = "19:11:23 PM" result = parse_date_str(input_format) self.assertEqual("%H:%M:%S %p", result)
def test_parser__shortDayddthShortMonthYYYY(self): input_format = "Mon 9th Jan 2020" result = parse_date_str(input_format) self.assertEqual("%a %dth %b %Y", result)
def test_parser__ddLongMonthyyyy_space_delim(self): input_format = "21 February 2020" result = parse_date_str(input_format) self.assertEqual("%d %B %Y", result)
def test_parser__ddShortMonthyyyy_space_delim(self): input_format = "21 Feb 2020" result = parse_date_str(input_format) self.assertEqual("%d %b %Y", result)
def format(): dt = request.form["dateFormat"] formatted = parse_date_str(dt) if not formatted: return "", 400 return jsonify({"message": f".strftime('{formatted}')"})