Open jacekchalupka opened 5 years ago
>>> dateparser.parse('10:10')
datetime.datetime(2019, 12, 12, 10, 10)
>>> dateparser.parse('today 10:10')
datetime.datetime(2019, 12, 12, 10, 10)
>>> dateparser.__version__
'0.7.2'
Did you set up system time correctly? Because the issue is only present if your local date is different than UTC date. At 0.7.2 I still get the bug
>>> dateparser.parse('10:10')
datetime.datetime(2019, 12, 11, 10, 10)
>>> dateparser.parse('today 10:10')
datetime.datetime(2019, 12, 12, 10, 10)
For more information:
λ python --version
Python 3.6.8
λ pip freeze
certifi==2019.9.11
chardet==3.0.4
dateparser==0.7.2
dictdiffer==0.8.0
idna==2.8
jenkinsapi==0.3.10
netaddr==0.7.19
python-dateutil==2.8.1
pytz==2019.3
regex==2019.12.9
requests==2.22.0
six==1.12.0
tzlocal==2.0.0
urllib3==1.25.6
I’m at UTC+1 at the moment:
>>> datetime.now()
datetime.datetime(2019, 12, 12, 14, 35, 54, 628271)
>>> datetime.utcnow()
datetime.datetime(2019, 12, 12, 13, 35, 58, 60252)
>>> dateparser.parse('10:10')
datetime.datetime(2019, 12, 12, 10, 10)
>>> dateparser.parse('today 10:10')
datetime.datetime(2019, 12, 12, 10, 10)
So there must be some other explanation.
Ok, the issue with your test is that date in UTC and locally is the same. If you are UTC+1 change time on your PC to 00:30 (30 minutes after midnight). That way locally it will be 12 of December and UTC will be 11 of December. Then do the same test.
Related to this: https://github.com/scrapinghub/dateparser/issues/307
When trying to parse time without date specified, returned date is inconsistent in different formats.
My computer date is set to: 2019.08.02 01:10 Timezone +2. It means that locally it is 2nd of August and in UTC it is 1st of August.
Notice that first parsed date have day in utc time and second in local time.
I believe local time zone should be used by default with option to pass timezone that user want to use.