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

Parse some abbreviated strings as relative dates #1219

Merged
merged 1 commit into from
Feb 16, 2024
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
2 changes: 1 addition & 1 deletion dateparser/data/date_translation_data/en.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@
"(?:12\\s+)?midnight": "00:00"
},
{
"(\\d+[.,]?\\d*)h(\\d+[.,]?\\d*)m?": "\\1:\\2"
"(\\d+[.,]?\\d*)h(\\d+[.,]?\\d*)": "\\1:\\2"
},
{
"(?<=from\\s+)now": "in"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ simplifications:
- a: '1'
- (?:12\s+)?noon: '12:00'
- (?:12\s+)?midnight: '00:00'
- (\d+[.,]?\d*)h(\d+[.,]?\d*)m?: \1:\2
- (\d+[.,]?\d*)h(\d+[.,]?\d*): \1:\2
- (?<=from\s+)now: in
- less than 1 minute ago: 45 second ago
- (\d+[.,]?\d*) (decade|year|month|week|day|hour|minute|second)s? later: in \1 \2
Expand Down
8 changes: 8 additions & 0 deletions tests/test_languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,14 @@ def test_translation(self, shortname, datetime_string, expected_translation):
param("en", "day before yesterday", "2 day ago"),
param("en", "last month", "1 month ago"),
param("en", "less than a minute ago", "45 second ago"),
param("en", "10h11", "10:11"),
param("en", "10h11m", "10 hour 11 minute"),
param("en", "3d8h2m", "3 day 8 hour 2 minute"),
param("en", "5d9h59m10s", "5 day 9 hour 59 minute 10 second"),
param("en", "3d1h", "3 day 1 hour"),
param("en", "3d29m", "3 day 29 minute"),
param("en", "1.5d10s", "1.5 day 10 second"),
param("en", "7m1s", "7 minute 1 second"),
# German
param("de", "vorgestern", "2 day ago"),
param("de", "heute", "0 day ago"),
Expand Down