Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corrected problem w/ locale in windows platforms #27

Merged
merged 2 commits into from
Nov 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions sgs/common.py
Expand Up @@ -5,6 +5,7 @@
import locale
import re
from typing import Union
import os


LRU_CACHE_SIZE = 32
Expand All @@ -15,6 +16,10 @@ def to_datetime(date_string: str, language: str) -> Union[datetime, str]:
""" Converts a date string to a datetime object """
locales = {"pt": "pt_BR.utf-8", "en": "en_US.utf-8"}

""" correct problem with locale in Windows platform """
if os.name == 'nt':
locales = {"pt": "Portuguese_Brazil.1252", "en": "Portuguese_Brazil.1252"}

locale.setlocale(locale.LC_TIME, locales[language])

dd_mm_aaaa = "%d/%m/%Y"
Expand Down