yaml / pyyaml

Canonical source repository for PyYAML
MIT License
2.55k stars 518 forks source link

Wrong parsing of year-month date #92

Closed crystalfp closed 6 years ago

crystalfp commented 6 years ago

A valid ISO8601 date containing only year and month (2017-09) is wrongly parsed if language is "it". Running the following code in November gives:

import dateparser

dt = dateparser.parse("2017-09", languages=["it"], settings={'PREFER_DAY_OF_MONTH': 'first', 'PREFER_DATES_FROM': 'past'})
print(dt.date()) #prints: 2017-11-09
dt = dateparser.parse("2017-09", settings={'PREFER_DAY_OF_MONTH': 'first', 'PREFER_DATES_FROM': 'past'})
print(dt.date()) #prints 2017-09-01

I'm forced to specify the language to cover ambiguous dates like 03/04/2017

Thanks for looking! mario

crystalfp commented 6 years ago

Forgot to add: python 3.6.2 on Windows 10 64 bits

cjerdonek commented 6 years ago

FYI, you filed this issue with the wrong project. The dateparser project is here: https://github.com/scrapinghub/dateparser

crystalfp commented 6 years ago

Oppssss.... Sorry.