Repository: scrapinghub/dateparser

Issue:
Formats like "1h20m" should be treated as relative but are actually absolute
When parsing a string like `"1h20m"`, it should be treated as a relative date; i.e. the same as it would treat the string `"1 hour and 20 minutes"`. However this is not the actual behaviour.

```py
>>> from datetime import datetime
>>> from dateparser import parse
>>> datetime.now()
datetime.datetime(2021, 10, 28, 18, 17, 11, 563442)
>>> parse("1h20m")
datetime.datetime(2021, 10, 28, 1, 20)
>>> parse("in 1h20m")
datetime.datetime(2021, 10, 28, 1, 20)
>>> parse("in 1 hour and 20 minutes")
datetime.datetime(2021, 10, 28, 19, 37, 34, 355178)
```


Discussion:
I agree that “in 1h20m” needs fixing, I’m less sure about the one without the “in”. I feel like for the interpretation of that one we should have a setting that could indicate if it should be interpreted as time in the future, time in the past, or absolute time (which I would keep as default).
Even with the setting to prefer in the future it still treats "1h20m" as absolute.

Also, I feel it would definitely make the most sense for "1h20m" and "1 hour 20 minutes" to give the same results as one is a literal abbreviation of the other.
Note that a space makes a difference:

```py
>>> parse("1h20m")
datetime.datetime(2021, 10, 28, 1, 20)
>>> parse("1h 20m")
datetime.datetime(2021, 10, 28, 16, 46, 56, 916241)
```
That is really counter intuitive. I think it would make most sense to make all those as relative.
A possible workaround for the time being:

```py
string = re.sub(r"([dhms])(\d)", r"\1 \2", "1h20m")
parse(string)
```

This will add a space which will cause it to be treated relatively



Patch:
diff --git a/dateparser/data/date_translation_data/en.py b/dateparser/data/date_translation_data/en.py
index b70975e1b..1409dcadb 100644
--- a/dateparser/data/date_translation_data/en.py
+++ b/dateparser/data/date_translation_data/en.py
@@ -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"
diff --git a/dateparser_data/supplementary_language_data/date_translation_data/en.yaml b/dateparser_data/supplementary_language_data/date_translation_data/en.yaml
index d103bc577..38b31297d 100644
--- a/dateparser_data/supplementary_language_data/date_translation_data/en.yaml
+++ b/dateparser_data/supplementary_language_data/date_translation_data/en.yaml
@@ -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


Test patch:
diff --git a/tests/test_languages.py b/tests/test_languages.py
index a4b28b982..f1525b446 100644
--- a/tests/test_languages.py
+++ b/tests/test_languages.py
@@ -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"),