Skip to content

Period: months/years not counted in total_seconds() #387

@zeebonk

Description

@zeebonk

Pendulum version: 2.0.5, possibly related to #346

Context
When working with classes/functions/APIs that expect some period be passed as number of seconds, I like to use a Duration + the total_seconds() function to clearly express what kind of period I'm passing.

Problem
I'm running into a situation where I want a period of a year in total seconds, but to my surprise I get 0 as a result. While experimenting I found that the same applies for months. Weeks and smaller seem to work as expected.

Examples

In [9]: pendulum.Duration(years=1).total_seconds()
Out[9]: 0.0

In [10]: pendulum.Duration(months=1).total_seconds()
Out[10]: 0.0

In [11]: pendulum.Duration(days=1).total_seconds()
Out[11]: 86400.0

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