You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to know when a date is incomplete and the missing parts #700
Is there a way to know when a date is incomplete. e.g "December 2015"
fromdateparserimportparseparse(u'December 2015') # default behaviordatetime.datetime(2015, 12, 16, 0, 0)
#is a way to do something like thisparse(u'December 2015', settings={'PREFER_DAY_OF_MONTH': 'incomplete'})
datetime.datetime(2015, 12, incomplete, 0, 0)
#the same with year or month
I need to parse data wich contains incomplete dates, in a nutshell i need the following to be done
fromdateparserimportparseparse(u'December 2015', settings={'PREFER_DAY_OF_MONTH': 'incomplete'}) #it could be a string or other typedatetime.datetime(2015, 12, incomplete, 0, 0)
i´m sorry about my english, im self taught in it...
The "period" indicates the smaller part (in this example "Month").
However, if the missing part is the year, for example, we won't be able to know it, so we should probably implement something new. I personally think that the best would be removing the "period" in a next major release (as it gives little information and if you want to add the "time", for example, you have to use a specific setting) and adding something like "found_parts" or something similar, indicating which "parts" were found, but this is something that we should decide in a calm and consensual way :P
Reacted by Bernhard Hering, Rishav C, Terrance and awiebe
changed the title [-]Question: is there a way to know when a date is incomplete.[/-][+]How to know when a date is incomplete and the missing parts[/+]on Nov 26, 2020
I would like period left in, but found parts should probably be added.
In my use case I am jamming a historical dates into a date field in a database, and using a second column to store the decision. I think a better name for period would be precision and it should have some constants
e.g.
fromdateparser.dateimportDateDataParser,Precisionddp=DateDataParser()
res=ddp.get_date_data('December 2015')
p : Precision=res.precisionifp==Precision.YEAR:
#...
Activity
Gallaecio commentedon Jun 1, 2020
I think this is a duplicate of #553
noviluni commentedon Jun 26, 2020
Just added a PR trying to find a solution for this: #729
Please, if you have any feedback let me know.
marcelooyaneder commentedon Jun 26, 2020
I've actually develop a little solution for that... on my testing is consistent, the code is the following.
in case that you need more feedback, just write me
noviluni commentedon Nov 26, 2020
Hi!
This can be partially achived by using
DateDataParser()andget_date_data()instead of using directlydateparser.parse().The "period" indicates the smaller part (in this example "Month").
However, if the missing part is the year, for example, we won't be able to know it, so we should probably implement something new. I personally think that the best would be removing the "period" in a next major release (as it gives little information and if you want to add the "time", for example, you have to use a specific setting) and adding something like "found_parts" or something similar, indicating which "parts" were found, but this is something that we should decide in a calm and consensual way :P
[-]Question: is there a way to know when a date is incomplete.[/-][+]How to know when a date is incomplete and the missing parts[/+]awiebe commentedon May 29, 2023
I would like period left in, but found parts should probably be added.
In my use case I am jamming a historical dates into a date field in a database, and using a second column to store the decision. I think a better name for
periodwould beprecisionand it should have some constantse.g.