Skip to content

FEAT: Update str and repr of Period objects #112

Description

@richjam

Describe the feature

Consider updating str and repr to more helpful strings, for use in e.g. logging / error messages.

e.g. currently:

p = Period.of_years(1).with_month_offset(9).with_hour_offset(9)

str(p) gives 'P1Y'
repr(p) gives 'P1Y+9MT9H[]'

Would be useful if str also gave the offset.

Also It has been mentioned that a "human readable" description of a Period object could be useful - e.g. for use in logging and error messages. 

e.g.

"P1D" = "1 day" or "Daily" or something... 

"P6M" = "6 months" 

"P1Y+9M9H" = "1 year + 9 months, 9 hours" ... or "UK Water Year"... 

Investigate how feasible this is and implement a property of the Period class. 

Motivation

More helpful represneation of period objects

Alternatives considered

No response

Additional context

https://jira.ceh.ac.uk/browse/FPM-291
https://jira.ceh.ac.uk/browse/FPM-538

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions