Tempora

5.8.1 · active · verified Sun Apr 12

Tempora is a Python library by `jaraco` providing a collection of objects and routines pertaining to date and time. It offers utilities and constants in its top-level package, routines for measuring and profiling in the `timing` module, an event scheduler in `schedule`, and functionalities for handling datetime-aware UTC values in `utc`. The library is currently at version 5.8.1 and maintains a regular release cadence with frequent updates.

Warnings

Install

Imports

Quickstart

Demonstrates basic usage of `tempora.timing.Stopwatch` for measuring execution time, `tempora.utc.now()` for getting current UTC time, and adding a simple task to `tempora.schedule.Scheduler`.

import datetime
from tempora.timing import Stopwatch
from tempora.schedule import Scheduler
from tempora.utc import now

# Example using Stopwatch
with Stopwatch() as sw:
    sum(range(10000))
print(f"Summing range took: {sw.elapsed} seconds")

# Example using utc.now()
utc_time = now()
print(f"Current UTC time: {utc_time}")

# Example using Scheduler (basic usage - requires a running event loop)
def my_task():
    print(f"Task executed at {now()}")

scheduler = Scheduler()
scheduler.add_event(my_task, datetime.timedelta(seconds=1))
print("Scheduler created to run a task after 1 second. (This example doesn't run the event loop).")

view raw JSON →