scrapinghub / scrapinghub/dateparser

Improve the `parsers` API

Open
#785 0 comments 0 reactions 1 assignee View on GitHub

@noviluni is already working on this.

Since Sep 21, 2020.

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

Description

Since this was merged: https://github.com/scrapinghub/dateparser/pull/603, the "parsers" API has been improving.

I think that we should define better what's a parser and define the same API for all of them, refactoring the code.

This would allow a clearer code, to ensure that all the rules (settings, etc) are applied in all the parsers, and it would also allow building some new fancy public functions to use the parsers directly like: parse_timestamp() or parse_absolute_time().

For that, we would move parts of the _DateLocaleParser logic inside each parser.

My idea is:

A "parser" is a function that receives a date_string and the settings and it returns the parsed datetime, None, or raises an error.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.