Skip to content

Leap year not working as expected with `'PREFER_DATES_FROM' #693

Closed

Description

@noviluni

I tried to execute:

dateparser.parse("29/2 10:30:02", settings={'PREFER_DATES_FROM': 'future'})

and it returns None.

Activity

  1. kishan3 commented on Jun 9, 2020

    @kishan3
    Contributor

    Hi @noviluni I am getting response in the latest version 0.7.4

    In [1]: import dateparser
    
    In [2]: dateparser.__version__
    Out[2]: '0.7.4'
    
    In [3]: dateparser.parse("29/2 10:30:02", settings={'PREFER_DATES_FROM': 'future'})
       ...: 
    Out[3]: datetime.datetime(2029, 2, 9, 10, 30, 2)
    
    
  2. noviluni commented on Jun 10, 2020

    @noviluni
    ContributorAuthor

    hhmmmm... I don't know why I was receiving None, but even if it returns something, I think that the result is wrong, as it's interpreting the 29 as a year without any apparent reason.

    Look these two examples, especially the second one.

    >>> dateparser.parse("29 Feb", settings={'PREFER_DATES_FROM': 'future'})                                                  
    datetime.datetime(2029, 2, 10, 0, 0)
    
    >>> dateparser.parse("29 Feb", settings={'PREFER_DATES_FROM': 'past'})                                                    
    datetime.datetime(2020, 2, 29, 0, 0)
    >>> dateparser.parse("29 Feb", settings={'PREFER_DATES_FROM': 'future','RELATIVE_BASE': datetime.datetime(2020, 1, 1)})  
    datetime.datetime(2020, 2, 29, 0, 0)
    
    >>> dateparser.parse("29 Feb", settings={'PREFER_DATES_FROM': 'past','RELATIVE_BASE': datetime.datetime(2020, 1, 1)})    
    datetime.datetime(1929, 2, 1, 0, 0)

    I think we should check it carefully.

    Related with: #520

  3. kishan3 commented on Jun 10, 2020

    @kishan3
    Contributor

    Right, Maybe we can update the issue so it reflects the actual issue. What do you think?

  4. changed the title [-]Leap year not working with `'PREFER_DATES_FROM': 'future'`[/-] [+]Leap year not working as expected with `'PREFER_DATES_FROM'[/+] on Jun 11, 2020
  5. Gallaecio commented on Jul 13, 2020

    @Gallaecio
    Contributor

    Fixed by #738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions