Skip to main content

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:0112:12).
  • Timezone-aware via zoneinfo (stdlib) and optional tzdata.

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:01 to 12: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
    Returns True if dt is a mirror hour.

    • tz: IANA timezone name (e.g., Europe/Madrid).
    • use_24h: if True, checks HH == MM in 24-hour clock; if False, checks 12-hour mirror set (01:0112:12).
  • next_mirror_time(dt: datetime | None = None, *, tz: str | None = None, use_24h: bool = True) -> datetime
    Returns the next mirror hour (timezone-aware if tz provided). If dt is exactly on a mirror minute, returns dt.

  • all_mirror_times(day: date | None = None, *, use_24h: bool = True) -> list[datetime.time]
    Returns all mirror times for a day (naive time objects).

    • 24h: 00:00, 01:01, …, 23:23 (24 items).
    • 12h: 01:01, …, 12:12 (12 items).

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 tzdata and pass --tz <ZONE>.
  • CLI not found: ensure the environment is active (.venv) and that mirrorhour is on PATH, or run python -m mirrorhour.cli.

License & Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mirrorhour-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mirrorhour-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

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

Hashes for mirrorhour-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b97a3009e599ecf74d87975eff11fd4d35b3119503cc61419b4f5d0be291edde
MD5 407d8ad9ef64e39c76ffae6b2d634ae9
BLAKE2b-256 ee6302d0cb84662efd4393791d1b733a3765b274515de4e7280002648572ddf6

See more details on using hashes here.

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

Hashes for mirrorhour-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a885c96885183905738e85bbd1b3562762ec2ab0f479cc74c47a8fd1d512ae1f
MD5 056c8b09b4b1f4fa4d901e55f4ad9a3f
BLAKE2b-256 43aa59364b841c91b960444deba98f1bdfb0718715c99d8a65b2f501ee11ff8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page