Skip to content

timestring: work around 29th February bug #181

Closed

Description

@GraemeWatt

The timestring.Date function is currently called in four places:

return timestring.Date(datafield.find_all(code=code)[0].string).year

return date, timestring.Date(date).year

year = timestring.Date(record['creation_date']).year

year = timestring.Date(record['creation_date']).year

There is a bug when timestring.Date is called on 29th February and the year passed is not a leap year:

>>> import timestring
>>> timestring.Date("2001-07-01")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/graemewatt/.virtualenvs/hepdata/lib/python2.7/site-packages/timestring/Date.py", line 150, in __init__
    new_date = new_date.replace(year=year)
ValueError: day is out of range for month

This bug should be worked around or the dependence on timestring.Date removed.

See also codecov/timestring#38, codecov/timestring#39, codecov/timestring#62, codecov/timestring#63.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions