polymerist.genutils.duration

Utilities for representing, converting, and formatting amounts of time

Attributes

SECONDS_PER_INTERVAL

SECONDS_PER_INTERVAL_ORDERED

Timeable

istimeable

Classes

TimeTemplate

Like a string Template, but which uses a percent to indicate fields (much like a date formatter)

Duration

For representing, converting, and formatting a length of time

Timer

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.Template

Like 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

to_seconds() float[source]

Convert the stored duration into a number of seconds

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
class polymerist.genutils.duration.Timer[source]

Simple context manager for measuring how long something takes

start_time
time_taken = None