scrapinghub / scrapinghub/dateparser

Unable to parse "12am last monday", and "12am monday" defaults to the upcoming monday

Open
#898 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
520
Avg merge
22h 56m
Merged PRs (30d)
6

Description

It looks like several of these formats cannot be parsed. It looks like "monday" is converted to this week's Monday (since today is Sunday, that is tomorrow).

Is there a way to get "last monday" from Dateparser? "Last week" works, but not "Last Monday" nor "Last Week on Monday"

#!/usr/bin/env python3
import dateparser

print(f"Now:            {dateparser.parse('now')}")
print(f"Monday:         {dateparser.parse('monday')}")
print(f"This Monday:    {dateparser.parse('this monday')}")
print(f"Last Monday:    {dateparser.parse('last monday')}")
print(f"Last Week:      {dateparser.parse('last week')}")
print(f"Last Week@6:    {dateparser.parse('last week at 6am')}")
print(f"Last Week Mon:  {dateparser.parse('last week on Monday')}")
print(f"A Week Ago:     {dateparser.parse('a week ago')}")
print(f"A Week Ago Mon: {dateparser.parse('a week ago on Monday')}")
Now:            2021-03-28 21:23:52.948271
Monday:         2021-03-29 00:00:00
This Monday:    None
Last Monday:    None
Last Week:      2021-03-21 21:23:54.180324
Last Week@6:    2021-03-21 06:00:00
Last Week Mon:  None
A Week Ago:     2021-03-21 21:23:54.201582
A Week Ago Mon: None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproduction script through dateparser.parse and trace how weekday and relative-date expressions are handled. Add regression coverage for the listed Monday and midnight cases, then verify that the requested expressions parse with the intended previous-week results instead of returning None or selecting the upcoming Monday.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.