Skip to content

Parsing with %j format #271

Closed
Closed

Description

@dsuch

Hello,

this is to report what I believe is a certain inconsistency in parsing the %j date format. Please find it below.

from dateparser import parse

value1 = '1999001'
value2 = '1999050'
value3 = '1999777'

date_formats = ['%Y%j']

result1 = parse(value1, date_formats)
print(result1)

result2 = parse(value2, date_formats)
print(result2)

result3 = parse(value3, date_formats)
print(result3)

Results:

1999-01-31 00:00:00 # Date should be Jan 1
1999-02-28 00:00:00 # Date should be Feb 19
9977-01-09 07:00:00 # Should likely raise an exception on invalid day of the year?

I'm using dateparser 0.5.1 with Python 2.7.6 on Ubuntu 14.04 64-bit.

I realize that %j is a rather obscure pattern but I'm submitting the ticket for completeness.

Regards.

Activity

  1. inishchith commented on Mar 4, 2017

    @inishchith

    Sir @dsuch , Can you please refer the mentions of %j date format . Because i think this inconsistency is due to use of arbitrary date format . just check the Supported date Formats
    under "_no_spaces_parser" class .

    @waqasshabbir Should i add a raise exception here ?.
    thanks .

  2. dsuch commented on Mar 4, 2017

    @dsuch
    Author

    Hello @inishchith,

    %j is a format commonly used in mainframe computers, it's not an arbitrary one and is documented here:

    https://docs.python.org/2/library/time.html#time.strftime
    https://docs.python.org/3/library/time.html#time.strftime

    Naturally, you will do what you think is best for this project. I just reported an issue because this is one of existing formats and the way it was handled was inconsistent.

  3. inishchith commented on Mar 4, 2017

    @inishchith

    Oh Got it @dsuch . How can i assign this work to myself ?
    @waqasshabbir should i work on adding support to %Y%j formats under _no_spaces_parser ? .

  4. dsuch commented on Mar 4, 2017

    @dsuch
    Author

    Hi @inishchith,

    I'm not one of developers in this project, I'm not sure how it's best to tackle the situation. I understand that @waqasshabbir is the lead so it would be prudent to wait for his opinion.

    Kind regards.

  5. self-assigned this
    on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions