scrapinghub / scrapinghub/dateparser
Dateparser does not currently recognized Timestamp format
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
Dateparser currently does not recognize 'TimeStamp' formats. When parsing through a document sometimes I need to parse 'TimeStamp' formats. Using Dateparser, it currently brings back null values. I suggest incorporating something like the following code to test if it is in TimeStamp format. Something like the example below will help to keep your dateparser format working if values are in a 'TimeStamp' format.
import re
import logging
import dateparser
from dateparser import parse
def dateparser(dt_input):
try:
if "timestamp" in dt_input.lower():
dt_input = dt_input.split('(')[1][:-1]
dt_input_parsed = parse(str(dt_input))
return dt_input_parsed
except:
logging.warning(f"No timestamp found in: {dt_input}")
Example:
>>> dateparser("Timestamp('2019-10-19 20:28:35.973000')")
datetime.datetime(2019, 10, 19, 20, 28, 35, 973000)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the public dateparser.parse entry point and reproduce the reported Timestamp('2019-10-19 20:28:35.973000') example. Trace how the input is handled and add coverage for this format; done means it returns the expected datetime instead of null while preserving existing parsing behavior.
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