10 examples of 'input date in python' in Python

Every line of 'input date in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
21def date(value, format='%Y-%m-%d'):
22 '''
23 >>> date('2000-01-01')
24 datetime.date(2000, 1, 1)
25 '''
26 return DateTime.strptime(value, format).date()
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

531def _convert_to_datetime(self, date, input_format):
532 if isinstance(date, datetime):
533 return date
534 if is_number(date):
535 return self._seconds_to_datetime(date)
536 if is_string(date):
537 return self._string_to_datetime(date, input_format)
538 raise ValueError("Unsupported input '%s'." % date)
370def parse(self, s):
371 """
372 Parses a date string formatted like ``YYYY-MM-DD``.
373 """
374 return datetime.datetime.strptime(s, self.date_format).date()
73def python_to_ABAP_date(py_date):
74 return "{:04d}{:02d}{:02d}".format(py_date.year, py_date.month, py_date.day)
254def date_str(s):
255 return datetime.datetime.strptime(s, '%Y-%m-%d').date()
15def test_http_date_python(self):
16 format_date_time(time())
371def inputDate(msg):
372 while True:
373 try:
374 date = input(msg)
375 except KeyboardInterrupt:
376 return
377 if date.lower() == "q":
378 return
379 try:
380 return dateDecode(date)
381 except Exception as e:
382 print(str(e))
39def convert_date(date):
40 return datetime.datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ")
26def sanitize_date(i: str) -> str:
27 # translate germany -> english
28 string = (i.replace(".", "")
29 .replace("Mär", "Mar")
30 .replace("Mai", "May")
31 .replace("Okt", "Oct")
32 .replace("Dez", "Dec"))
33 return datetime.datetime.strptime(string, "%d %b %Y").strftime("%Y-%m-%d")
37def parseDate(date):
38 if isinstance(date, str):
39 try:
40 return duparser.parse(date)
41 except Exception:
42 pass

Related snippets