Visitar URL original
parse of date with duration cause error · Issue #881 · python-pendulum/pendulum · GitHub
Skip to content

parse of date with duration cause error #881

Description

@mlongtin0
  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: Ubuntu 22.04.5 LTS
  • Pendulum version: 3.0.0
  • Python version: 3.10.12

Issue

Parsing duration with dates does this:

>>> pendulum.parse("2025-03-10/P3D")
...
TypeError: Date.add() got an unexpected keyword argument 'hours'

However, adding an hour to the date string works:

>>> pendulum.parse("2025-03-10T00/P3D")
<Interval [2025-03-10 00:00:00+00:00 -> 2025-03-13 00:00:00+00:00]>

It seems the internal datetime object is type Date, which doesn't support add(hours=...)

Activity

  1. himanshubohra13 commented on Mar 25, 2025

    @himanshubohra13

    Hey @mlongtin0
    Can I look into this issue?

  2. dreglad commented on Apr 30, 2025

    @dreglad

    I’m also seeing a related but distinct issue when supplying only the year,

    >>> pendulum.parse("2025/P1Y")
    
    # ./pendulum/parsing/__init__.py", line 125, in _parse
    #    raise ParserError(f"Unable to parse string [{text}]")
    # pendulum.parsing.exceptions.ParserError: Unable to parse string [2025/P1Y]
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