scrapinghub / scrapinghub/dateparser

In case of incomplete dates like '2013', would it be better to add a parameter like 'PREFER_MONTH_OF_YEAR' ?

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

Nobody has claimed this yet.

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

Description

# current
>>> parse('2013', settings={'PREFER_DAY_OF_MONTH': 'first'})`
datetime.datetime(2013, 8, 1, 0, 0)

# expected
>>> parse('2013', settings={'PREFER_DAY_OF_MONTH': 'first', 'PREFER_MONTH_OF_YEAR': 'first'})
datetime.datetime(2013, 1, 1, 0, 0)

>>> parse('2013', settings={'PREFER_DAY_OF_MONTH': 'first', 'PREFER_MONTH_OF_YEAR': 'current'})
datetime.datetime(2013, 8, 1, 0, 0)

>>> parse('2013', settings={'PREFER_DAY_OF_MONTH': 'first', 'PREFER_MONTH_OF_YEAR': 'last'})
datetime.datetime(2013, 12, 1, 0, 0)

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 reviewing how the existing PREFER_DAY_OF_MONTH setting is handled when parsing an incomplete year such as '2013'. Compare the proposed first, current, and last month behaviors in the issue, then identify the relevant parser tests or entry points and define completion as matching all three expected datetime results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.