Created
March 26, 2015 08:00
-
-
Save savanovich/e7fe337fcc64ed33a905 to your computer and use it in GitHub Desktop.
PY: Format datetile in locale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import locale | |
from datetime import datetime, timedelta | |
try: | |
locale.setlocale(locale.LC_TIME, '%s.UTF-8' % lang) | |
except Exception as e: | |
logger.error("Error setting exception", lang=lang, exception=e) | |
# English locale | |
locale.setlocale(locale.LC_TIME, 'en_US.UTF-8') | |
result = date_.strftime("%d %b %Y %H:%M") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment