polymerist.genutils.duration
Utilities for representing, converting, and formatting amounts of time
Attributes
Classes
Like a string Template, but which uses a percent to indicate fields (much like a date formatter) |
|
For representing, converting, and formatting a length of time |
|
Simple context manager for measuring how long something takes |
Module Contents
- polymerist.genutils.duration.SECONDS_PER_INTERVAL
- polymerist.genutils.duration.SECONDS_PER_INTERVAL_ORDERED
- type polymerist.genutils.duration.Timeable = int | float | timedelta
- polymerist.genutils.duration.istimeable
- class polymerist.genutils.duration.TimeTemplate(template)[source]
Bases:
string.TemplateLike a string Template, but which uses a percent to indicate fields (much like a date formatter)
- delimiter: str = '%'
- class polymerist.genutils.duration.Duration[source]
For representing, converting, and formatting a length of time
- year: int = 0
- day: int = 0
- hour: int = 0
- minute: int = 0
- second: int = 0
- millisecond: int = 0
- microsecond: int = 0
- classmethod from_seconds(interval: Timeable) dict[str, int][source]
Takes an object interpretable as a duration in seconds and returns the breakdown by years, hours, minutes, seconds, and milliseconds
- property total_seconds: float
conversion-to-seconds alias for convenience
- format(fmt_str: str) str[source]
Format stored duration similar to datetime.strftime (https://docs.python.org/3/library/datetime.html#datetime.datetime.strftime)
- fmt