Repository: TRoboto/Maha

Issue:
Last day of month parsing returns incorrect date
### What happened?

Check the following example:

```py
>>> from datetime import datetime
>>> from maha.parsers.functions import parse_dimension
>>> date = datetime(2021, 9, 21)
>>> sample_text = "آخر اثنين من شهر شباط"
>>> parse_dimension(sample_text, time=True)[0].value + date
datetime.datetime(2021, 3, 15, 0, 0)
```

Obviously this is wrong, we're asking for February while it returns March.  The correct answer is:
```py
datetime.datetime(2021, 2, 22)
```


### Python version

3.8

### What operating system are you using?

Linux

### Code to reproduce the issue

_No response_

### Relevant log output

_No response_

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/TRoboto/Maha/pull/30?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani) Report
> Merging [#30](https://codecov.io/gh/TRoboto/Maha/pull/30?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani) (62e2526) into [main](https://codecov.io/gh/TRoboto/Maha/commit/a576d5385f6ba011f81cf8d0e69f52f756006489?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani) (a576d53) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/TRoboto/Maha/pull/30/graphs/tree.svg?width=650&height=150&src=pr&token=9CBWXT8URA&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani)](https://codecov.io/gh/TRoboto/Maha/pull/30?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani)

```diff
@@           Coverage Diff           @@
##             main      #30   +/-   ##
=======================================
  Coverage   97.53%   97.53%           
=======================================
  Files          61       61           
  Lines        2188     2188           
=======================================
  Hits         2134     2134           
  Misses         54       54           
```


| [Impacted Files](https://codecov.io/gh/TRoboto/Maha/pull/30?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani) | Coverage Δ | |
|---|---|---|
| [maha/parsers/rules/time/values.py](https://codecov.io/gh/TRoboto/Maha/pull/30/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani#diff-bWFoYS9wYXJzZXJzL3J1bGVzL3RpbWUvdmFsdWVzLnB5) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/TRoboto/Maha/pull/30?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/TRoboto/Maha/pull/30?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani). Last update [a576d53...62e2526](https://codecov.io/gh/TRoboto/Maha/pull/30?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mohammad+Al-Fetyani).


Patch:
diff --git a/maha/parsers/rules/time/values.py b/maha/parsers/rules/time/values.py
index 7c581a6..4a7d08e 100644
--- a/maha/parsers/rules/time/values.py
+++ b/maha/parsers/rules/time/values.py
@@ -729,13 +729,9 @@ _start_of_last_day = (
 LAST_SPECIFIC_DAY_OF_SPECIFIC_MONTH = FunctionValue(
     lambda match: parse_value(
         {
-            "month": _months.get_matched_expression(match.group("month")).value.month  # type: ignore
-            + 1
-            if _months.get_matched_expression(match.group("month")).value.month  # type: ignore
-            + 1
-            <= 12
-            else 1,
+            "month": _months.get_matched_expression(match.group("month")).value.month,  # type: ignore
             "weekday": _days.get_matched_expression(match.group("day")).value(-1),  # type: ignore
+            "day": 31,
         }
     ),
     spaced_patterns(_start_of_last_day, named_group("month", _months.join())),


Test patch:
diff --git a/tests/parsers/test_time.py b/tests/parsers/test_time.py
index 8fa926c..57182e3 100644
--- a/tests/parsers/test_time.py
+++ b/tests/parsers/test_time.py
@@ -726,6 +726,20 @@ def test_time(expected, input):
     assert_expression_output(output, expected)
 
 
+@pytest.mark.parametrize(
+    "expected,input",
+    [
+        (NOW.replace(day=30), "آخر خميس من شهر 9"),
+        (NOW.replace(day=29), "آخر اربعاء من شهر 9"),
+        (NOW.replace(day=22, month=2), "آخر اثنين من شهر شباط"),
+        (NOW.replace(day=28, month=2), "آخر احد من شهر شباط"),
+    ],
+)
+def test_last_specific_day_of_specific_month(expected, input):
+    output = parse_dimension(input, time=True)
+    assert_expression_output(output, expected)
+
+
 @pytest.mark.parametrize(
     "input",
     [