Skip to content

Erroneous bounds checking for day of month when using truncated year of decade #264

Description

@MetRonnie

Cannot create what ought to be a valid truncated TimePoint:

>>> TimePoint(year=2, month_of_year=2, day_of_month=29, truncated=True, truncated_property='year_of_decade')
...
BadInputError: Invalid input (out of bounds): day_of_month: 29

But year of decade = 2 could be a leap year, for example 2012.

Solution

  • Year of decade: 29th Feb is valid if year of decade is divisible by 2
  • Year of century: 29th Feb is valid if year of century is divisible by 4

If fixed, would expect:

>>> trunc_args = {'truncated': True, 'truncated_property': 'year_of_decade'}
>>> TimePoint(year=2, month_of_year=2, day_of_month=29, **trunc_args) + TimePoint(year=2007)
<metomi.isodatetime.data.TimePoint: 2012-02-29T00:00:00Z>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions