-
Notifications
You must be signed in to change notification settings - Fork 92
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
I want to get datetime in Japanese news. #58
Comments
result['date'] is working, datetime is not always available, will check alternative solution later. |
I had the same problem for Dutch. def define_date(date):
months = {"jan": 1, "feb": 2, "mar": 3, "apr": 4, "mei": 5, "jun": 6, "jul": 7, "aug": 8, "sep": 9, "okt": 10,
"nov": 11, "dec": 12}
try:
if "geleden" in date.lower():
q = int(date.split()[-3])
if re.search(r"(minuten|minuut)", date.lower()):
return dt.datetime.now() + relativedelta(minutes=-q)
elif re.search(r"(uur|uren)", date.lower()):
return dt.datetime.now() + relativedelta(hours=-q)
elif re.search(r"(dag|dagen)", date.lower()):
return dt.datetime.now() + relativedelta(days=-q)
elif re.search(r"(week|weken)", date.lower()):
return dt.datetime.now() + relativedelta(days=-7 * q)
elif re.search(r"(maand|maanden)", date.lower()):
return dt.datetime.now() + relativedelta(months=-q)
elif "gisteren" in date.lower():
return dt.datetime.now() + relativedelta(days=-1)
else:
for month in months.keys():
if month.lower() + " " in date.lower():
date_list = date.replace(",", "").split()[-3:]
return dt.datetime(day=int(date_list[1]), month=months[month], year=int(date_list[2]))
except:
return float("nan") The function would need to be adapted for every language. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, I did get news in Japanese, datetime is set to None.
But I did changed language to en, datetime is setted. please fix it.
The text was updated successfully, but these errors were encountered: