⏱️ timesaver
A lightning-fast, zero-dependency micro-library to instantly convert messy machine data (raw bytes, seconds, and dates) into sleek, human-readable strings.
🚀 Why timesaver?
Most "humanizing" packages suffer from feature creep—carrying heavy translation files, scientific formulas, and massive footprints. timesaver is built for developers who just want sleek, dashboard-ready strings with zero bloat.
- Ultra-lightweight: Zero external dependencies. Perfect for AWS Lambda or microservices.
- Smart Types: Automatically handles both Python
datetimeand pure calendardateobjects. - Tech-Friendly: Formats strings cleanly (
15m agoinstead offifteen minutes ago) to fit beautiful UI layouts.
📦 Installation
Install it instantly via pip:
pip install timesaver
💻 Quick Start & Examples
Humanizing File Sizes (filesize)
Convert large integers of bytes into dynamically scaled, clean string readouts.
import timesaver
print(timesaver.filesize(1024)) # Output: "1.0 KB"
print(timesaver.filesize(5432100)) # Output: "5.2 MB"
print(timesaver.filesize(1200000000)) # Output: "1.1 GB"
Smart Relative Time (ago)
Pass either a high-precision datetime object or a standard calendar date object. The engine will automatically calculate the difference relative to right now.
import timesaver
import datetime as dt
# Example A: Using a precise datetime (e.g., 15 minutes ago)
past_datetime = dt.datetime.now() - dt.timedelta(minutes=15)
print(timesaver.ago(past_datetime)) # Output: "15m ago"
# Example B: Using a pure calendar date (e.g., 5 days ago)
past_date = dt.date.today() - dt.timedelta(days=5)
print(timesaver.ago(past_date)) # Output: "5d ago"
🛠️ API Reference
timesaver.filesize(bytes_count: int) -> str
Takes an integer representing bytes. Scaled automatically across B, KB, MB, GB, TB, and PB. Raises a ValueError if the number is negative.
timesaver.ago(timestamp: Union[datetime, date]) -> str
Calculates distance from the current time. Breaks down into thresholds:
< 60 seconds -> "just now"
< 1 hour -> "Xm ago"
< 24 hours -> "Xh ago"
< 30 days -> "Xd ago"
< 12 months -> "Xmo ago"
> 1 year -> "Xy ago"
Metadata
Release files for timesaver 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| timesaver-0.1.2.tar.gz | 3.2 kB | Without provenance | Details for timesaver-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| timesaver-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for timesaver-0.1.2-py3-none-any.whl |
Total release size: 6.7 kB
Release files / timesaver-0.1.2.tar.gz
| Download URL | timesaver-0.1.2.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
744155e7142c07dd8e3c6c802ee4d72e2ab8615a4a0b201a3c5f1bfb04e4ffc4
|
|
BLAKE2b-256 checksum How to use checksums |
1573184db2ad372ec349c4cb3069f396143ae861debe1da9e67389c38a79e3ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / timesaver-0.1.2-py3-none-any.whl
| Download URL | timesaver-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba1caa97609a8609bad9dc63adb7318f6f17965f4fb2e0b826717b54a90bdc41
|
|
BLAKE2b-256 checksum How to use checksums |
781f372ccce3f03652bf47d8ddbedcbe7f2f22293aa0ba9a09095ceececb80b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Security for timesaver 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.