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

Hotfix id sunday #1134

Merged
merged 4 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion dateparser/data/date_translation_data/id.py
Expand Up @@ -202,7 +202,8 @@
],
"\\1 week ago": [
"(\\d+[.,]?\\d*) mgg lalu",
"(\\d+[.,]?\\d*) minggu yang lalu"
"(\\d+[.,]?\\d*) minggu yang lalu",
"(\\d+[.,]?\\d*) minggu lalu"
],
"\\1 year ago": [
"(\\d+[.,]?\\d*) tahun yang lalu",
Expand Down Expand Up @@ -235,6 +236,12 @@
"in \\1 year": [
"dalam (\\d+[.,]?\\d*) tahun",
"dlm (\\d+[.,]?\\d*) thn"
],
"\\1 week": [
"(\\d+[.,]?\\d*) minggu"
],
"sunday": [
"minggu"
]
},
"locale_specific": {},
Expand Down
1 change: 1 addition & 0 deletions dateparser/languages/locale.py
Expand Up @@ -134,6 +134,7 @@ def translate(self, date_string, keep_formatting=False, settings=None):
for pattern, replacement in relative_translations.items():
if pattern.match(word):
date_string_tokens[i] = pattern.sub(replacement, word)
break
else:
if word in dictionary:
fallback = word if keep_formatting and not word.isalpha() else ''
Expand Down
Expand Up @@ -30,8 +30,13 @@ relative-type:
- baru saja

relative-type-regex:
\1 week ago:
- (\d+[.,]?\d*) minggu lalu
\1 month ago:
- (\d+[.,]?\d*) bulan lalu

\1 year ago:
- (\d+[.,]?\d*) tahun lalu
\1 week:
- (\d+[.,]?\d*) minggu
sunday:
- minggu
5 changes: 1 addition & 4 deletions tests/test_data.py
Expand Up @@ -62,10 +62,7 @@ def is_invalid_relative_regex_mapping(relative_regex_mapping):
key, value = relative_regex_mapping
if not (key and value and isinstance(key, str) and isinstance(value, list)):
return True
if '\\1' not in key:
return True
return not (all([isinstance(x, str) for x in value])
and all(['(\\d+[.,]?\\d*)' in x for x in value]))
return not all([isinstance(x, str) for x in value])


class TestLocaleInfo(BaseTestCase):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_languages.py
Expand Up @@ -131,9 +131,13 @@ def setUp(self):
# Tagalog
param('tl', "Biyernes Hulyo 3, 2015", "friday july 3 2015"),
param('tl', "Pebrero 5, 2015 7:00 pm", "february 5 2015 7:00 pm"),

# Indonesian
param('id', "06 Sep 2015", "06 september 2015"),
param('id', "07 Feb 2015 20:15", "07 february 2015 20:15"),
param('id', "Minggu, 18 Mar 2018 07:30", "sunday 18 march 2018 07:30"),
param('id', "3 minggu yang lalu", "3 week ago"),
param('id', "5 minggu", "5 week"),

# Miscellaneous
param('en', "2014-12-12T12:33:39-08:00", "2014-12-12 12:33:39-08:00"),
Expand Down