Skip to content

Commit

Permalink
extract datetime without setting locale
Browse files Browse the repository at this point in the history
  • Loading branch information
Siavash Mollayi committed Dec 25, 2021
1 parent d449931 commit 575299c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lingua_franca/lang/parse_az.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

from typing import List
from datetime import datetime, timedelta
import locale
locale.setlocale(locale.LC_TIME, "az_AZ")
from dateutil.relativedelta import relativedelta

from lingua_franca.time import now_local
Expand Down Expand Up @@ -719,6 +717,9 @@ def date_found():
months = ['yanvar', 'fevral', 'mart', 'aprel', 'may', 'iyun',
'iyul', 'avqust', 'sentyabr', 'oktyabr', 'moyabr',
'dekabr']
eng_months = ['january', 'february', 'march', 'april', 'may', 'june',
'july', 'august', 'september', 'october', 'november',
'december']
word_list += days + months
recur_markers = days + [_generate_plurals_az(d) for d in days] + ['həftə sonu', 'iş günü',
'həftə sonları', 'iş günləri']
Expand Down Expand Up @@ -859,7 +860,7 @@ def date_found():
except ValueError:
m = monthsShort.index(word)
used += 1
datestr = months[m]
datestr = eng_months[m]
if wordPrev and wordPrev[0].isdigit():
datestr += " " + wordPrev
start -= 1
Expand Down Expand Up @@ -1162,7 +1163,7 @@ def date_found():
if secOffset != 0:
extractedDate = extractedDate + relativedelta(seconds=secOffset)
for idx, word in enumerate(words):
if words[idx] == "and" and \
if words[idx] == "" and \
words[idx - 1] == "" and words[idx + 1] == "":
words[idx] = ""

Expand Down

0 comments on commit 575299c

Please sign in to comment.