scrapinghub / scrapinghub/dateparser

+ operator interpreted as minus

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

Nobody has claimed this yet.

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

Description

╰ ipython                                                                                                                                                                                                                                                                      
Python 3.6.5 (default, Nov 19 2018, 18:02:26)                                                                                                                                                                                                                                   
Type 'copyright', 'credits' or 'license' for more information                                                                                                                                                                                                                   
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                
In [1]: import dateparser                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                
In [2]: dateparser.parse("now")                                                                                                                                                                                                                                                 
Out[2]: datetime.datetime(2019, 5, 15, 17, 15, 29, 500448)                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                
In [3]: dateparser.parse("now + 1hr")                                                                                                                                                                                                                                           
Out[3]: datetime.datetime(2019, 5, 15, 16, 15, 33, 317451)                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                
In [4]: dateparser.parse("now - 1hr")                                                                                                                                                                                                                                           
Out[4]: datetime.datetime(2019, 5, 15, 16, 15, 46, 960211)    

In [5]: dateparser.parse("now + 2hr")                                                                                                                                                                                                                                           
Out[5]: datetime.datetime(2019, 5, 15, 15, 15, 52, 693479)                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                
In [6]: dateparser.parse("now + 2hr")                                                                                                                                                                                                                                           
Out[6]: datetime.datetime(2019, 5, 15, 15, 15, 59, 263881)                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                
In [7]: dateparser.parse("now + 1 hour")                                                                                                                                                                                                                                        
Out[7]: datetime.datetime(2019, 5, 15, 16, 16, 44, 824766)                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                
In [8]: dateparser.parse("now + 10 minutes")                                                                                                                                                                                                                                    
Out[8]: datetime.datetime(2019, 5, 15, 17, 7, 9, 543897)

I tried both version 0.7.0 and 0.6.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 reproducing the examples through dateparser.parse, especially the differing results for "now + 1hr" and "now - 1hr". Trace the relative-expression parsing entry point and verify that plus applies a forward offset while minus applies a backward offset, including the hour and minute examples.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.