scrapinghub / scrapinghub/dateparser

Given a month with 32 days, dateparser fails with some years but parses with others

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

Nobody has claimed this yet.

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

Description

System

Ubuntu 18.04
Python 3.6.9

Description

Compare the following two snippets

from dateparser import parse

# None
parse("32 DEC 95", date_formats=["%d %b %y"])

and

from dateparser import parse

# 2032-12-10 00:00:00
parse("32 DEC 10", date_formats=["%d %b %y"])

In both cases December with 32 days is given. In the first case, suddenly the 32 becomes the year, even though date_formats specifies a different format.

Expected behavior

I would expect both of the parsed dates to be 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

Reproduce the two dateparser.parse calls from the issue with date_formats=["%d %b %y"] and compare their handling of the invalid 32nd day. Trace the parsing path for numeric day, month, and two-digit year values. Done means both inputs consistently return None, with regression coverage for the differing years.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.