Utilities to detect and work with mirror hours (HH:HH) in local time or arbitrary timezones.
Project description
mirrorhour
Utilities to detect and work with mirror hours (when hour and minute are equal, e.g., 11:11, 22:22) in local time or any IANA timezone. Provides a tiny Python API and a CLI.
Features
is_mirror_time(dt)— check if a datetime is a mirror hour.next_mirror_time(dt)— compute the next mirror hour.all_mirror_times()— list all mirror hours in a day.- Optional 12-hour mode (
01:01…12:12). - Timezone-aware via
zoneinfo(stdlib) and optionaltzdata.
Installation
pip install mirrorhour[cli]
# If your OS lacks a timezone database (common on Windows):
pip install tzdata
Quick Start (CLI)
# Installed script
mirrorhour --tz Europe/Madrid
# Run via Python module
python -m mirrorhour.cli --tz Europe/Madrid
# 12-hour mode
mirrorhour --tz Europe/Madrid --twelve
Options
--tz <ZONE>: IANA timezone (e.g.,Europe/Madrid).--twelve: Use 12-hour mirror mode (01:01to12:12).
Quick Start (Python)
from mirrorhour import is_mirror_time, next_mirror_time, all_mirror_times
from datetime import datetime
now = datetime.now()
if is_mirror_time(now):
print("It's a mirror hour!")
else:
print("Next mirror hour:", next_mirror_time(now))
print("All mirror hours (24h):", all_mirror_times())
API
-
is_mirror_time(dt: datetime | None = None, *, tz: str | None = None, use_24h: bool = True) -> bool
ReturnsTrueifdtis a mirror hour.tz: IANA timezone name (e.g.,Europe/Madrid).use_24h: ifTrue, checksHH == MMin 24-hour clock; ifFalse, checks 12-hour mirror set (01:01–12:12).
-
next_mirror_time(dt: datetime | None = None, *, tz: str | None = None, use_24h: bool = True) -> datetime
Returns the next mirror hour (timezone-aware iftzprovided). Ifdtis exactly on a mirror minute, returnsdt. -
all_mirror_times(day: date | None = None, *, use_24h: bool = True) -> list[datetime.time]
Returns all mirror times for a day (naivetimeobjects).- 24h:
00:00, 01:01, …, 23:23(24 items). - 12h:
01:01, …, 12:12(12 items).
- 24h:
Requirements
- Python ≥ 3.9
tzdata(only if your OS lacks an IANA timezone database)
Testing
# Recommended for development
python -m pip install -e .[cli]
pytest -q
Troubleshooting
- Timezone errors: install
tzdataand pass--tz <ZONE>. - CLI not found: ensure the environment is active (
.venv) and thatmirrorhouris on PATH, or runpython -m mirrorhour.cli.
License & Credits
- License: MIT
- Author: XaviDev41 (4152@xavi.com.es)
- Repository: https://github.com/XaviDev41/mirrorhour
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mirrorhour-0.1.0.tar.gz.
File metadata
- Download URL: mirrorhour-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b97a3009e599ecf74d87975eff11fd4d35b3119503cc61419b4f5d0be291edde
|
|
| MD5 |
407d8ad9ef64e39c76ffae6b2d634ae9
|
|
| BLAKE2b-256 |
ee6302d0cb84662efd4393791d1b733a3765b274515de4e7280002648572ddf6
|
File details
Details for the file mirrorhour-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mirrorhour-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a885c96885183905738e85bbd1b3562762ec2ab0f479cc74c47a8fd1d512ae1f
|
|
| MD5 |
056c8b09b4b1f4fa4d901e55f4ad9a3f
|
|
| BLAKE2b-256 |
43aa59364b841c91b960444deba98f1bdfb0718715c99d8a65b2f501ee11ff8c
|