Every line of 'python datetime formats' 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.
658 def test_format_datetime(): 659 dt = datetime(2007, 4, 1, 15, 30) 660 assert (dates.format_datetime(dt, locale='en_US') == 661 u'Apr 1, 2007, 3:30:00 PM') 662 663 full = dates.format_datetime(dt, 'full', tzinfo=timezone('Europe/Paris'), 664 locale='fr_FR') 665 assert full == (u'dimanche 1 avril 2007 à 17:30:00 heure ' 666 u'd\u2019\xe9t\xe9 d\u2019Europe centrale') 667 custom = dates.format_datetime(dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz", 668 tzinfo=timezone('US/Eastern'), locale='en') 669 assert custom == u'2007.04.01 AD at 11:30:00 EDT'
28 def format_datetime(value, format='medium'): 29 if format == 'full': 30 format="d. MMMM y 'at' HH:mm" 31 elif format == 'medium': 32 format="dd.MM.y HH:mm" 33 return dates.format_datetime(value, format)
43 def fmtdatetime(dt): 44 hour = datetime.strftime(dt, "%I").lstrip('0') 45 return datetime.strftime(dt, "%m/%d {0}%p".format(hour))