Skip to main content

Developers Toolbox

Expired

Tiny utility to check whether a timestamp has expired relative to the current UTC time. A value is expired when it is strictly earlier than (now - delta). With no window, delta is zero, so anything before UTC now is expired and a time equal to now is not.

The PyPI name is lupaxa-expired. The import path is lupaxa.expired. The console script is expired. lupaxa is a namespace package — there is no lupaxa/__init__.py.

Public names: is_expired, parse_datetime, make_delta, ExpiredError, ParseError, DEFAULT_FORMATS, __version__, get_version().

Install

pip install lupaxa-expired

Requires Python 3.10+. No runtime dependencies.

Library

from datetime import datetime, timezone
from lupaxa.expired import is_expired

if is_expired("2022-10-19 14:43:57.563803"):
    print("Expired")

cutoff = datetime(2025, 11, 6, tzinfo=timezone.utc)
is_expired("2025-10-01", days=3, now=cutoff)
is_expired(cutoff, now=cutoff)  # False — equal is not expired
Situation Result
when is earlier than the cutoff expired (True)
when equals the cutoff not expired
when is later than the cutoff not expired

now defaults to current UTC. delta defaults to zero. Naive datetimes are treated as UTC.

Pass a timedelta or keyword parts (years, months, weeks, days, hours, minutes, seconds). Parts add together and are ignored when delta= is set. fmt is a parse format, not a delta part. Years are 365 days and months are 30 days. An unknown part raises ExpiredError.

from lupaxa.expired import ExpiredError, ParseError, is_expired, make_delta, parse_datetime

is_expired("2025/11/01 14:43:57", fmt="%Y/%m/%d %H:%M:%S", days=2)
parse_datetime("2024-11-06T08:45:00Z")
make_delta(weeks=2, days=3)

Without fmt, strings are tried in this order:

Format Example
%Y-%m-%d %H:%M:%S.%f 2022-10-19 14:43:57.563803
%Y-%m-%d %H:%M:%S 2022-10-19 14:43:57
%Y-%m-%d 2022-10-19
%Y-%m-%dT%H:%M:%S.%fZ 2024-11-06T08:45:00.123456Z
%Y-%m-%dT%H:%M:%S.%f 2024-11-06T08:45:00.123456
%Y-%m-%dT%H:%M:%SZ 2024-11-06T08:45:00Z
%Y-%m-%dT%H:%M:%S 2024-11-06T08:45:00

The Z is a literal suffix, not a timezone conversion. Unparseable input raises ParseError (a subclass of ExpiredError).

CLI

expired --time "2022-10-19 14:43:57.563803"
expired --time "2022-10-19 14:43:57.563803" --days 3
expired --time "2024-11-06T09:00:00Z" --hours 12
expired --time "2024/11/06 09:00:00" --format "%Y/%m/%d %H:%M:%S" --days 1
expired --version

--time is required unless you pass --version.

Flag Meaning
--time Timestamp to check (required unless version)
--format Optional strptime format for --time
--years Years to subtract from now (365 days each)
--months Months to subtract from now (30 days each)
--weeks Weeks to subtract from now
--days Days to subtract from now
--hours Hours to subtract from now
--minutes Minutes to subtract from now
--seconds Seconds to subtract from now
--version Print expired x.y.z and exit 0
--help Show argparse help

The CLI prints expired or not expired.

Result Stdout Exit
Still valid not expired 0
Expired expired 1
--version expired x.y.z 0
Missing or bad time error on stderr 2

The if branch runs when the CLI exits 0 (not expired):

if expired --time "2022-10-19" >/dev/null; then
    echo "Still valid"
else
    echo "Date has expired or the input was invalid"
fi

Examples

from datetime import datetime, timezone
from lupaxa.expired import is_expired

timestamps = [
    "2022-09-01 12:00:00",
    "2024-10-01 12:00:00",
    "2025-01-01 12:00:00",
]
expired_items = [item for item in timestamps if is_expired(item)]

cutoff = datetime(2025, 11, 6, tzinfo=timezone.utc)
dates = ["2025-10-01", "2025-06-01", "2025-11-01"]
stale = [item for item in dates if is_expired(item, days=3, now=cutoff)]

Development

make init
make python-install-dev
make python-check
The Lupaxa Project Footer

Metadata

Release files for lupaxa-expired 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lupaxa-expired 0.1.6
File Size Uploaded
lupaxa_expired-0.1.6.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lupaxa-expired 0.1.6
File Interpreter ABI Platform
lupaxa_expired-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / lupaxa_expired-0.1.6.tar.gz

Download URL lupaxa_expired-0.1.6.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b8977f07ad6fc9ca3da2c84608f5764566eb9930579498fb8eb2f86f2ba3a94d
BLAKE2b-256 checksum
How to use checksums
e60f4f9700fcb0d10dd0f01403de124044a041c51cbaf5f10314664a476ca0d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / lupaxa_expired-0.1.6-py3-none-any.whl

Download URL lupaxa_expired-0.1.6-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f502afcc94fa8684a1edf85cbdfa4ccff322c2e3c66235ba2dec9bccde0fa9b3
BLAKE2b-256 checksum
How to use checksums
6f9de06accebb79f607f2dbc7d26602a037fefad5e48ff9f428cc44b2a20b968
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page