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.5

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.5
File Size Uploaded
lupaxa_expired-0.1.5.tar.gz 6.9 kB Details

Built distribution (wheel)

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

Total release size: 16.5 kB

Release files / lupaxa_expired-0.1.5.tar.gz

Download URL lupaxa_expired-0.1.5.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
959db7e724ac82fdc1e0fe4c73a0eda6f4e1fca3e587544525562952c8b325d2
BLAKE2b-256 checksum
How to use checksums
64e7dcbbd65c61a9f1b5736bd25599cb5d97ef40b4e50360c124a919cc536d34
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 Sep 30, 2026.

Transparency log

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

Download URL lupaxa_expired-0.1.5-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46dc81be39f01aa0825f2fd0153696550a90e452475209c5457a9f1856557261
BLAKE2b-256 checksum
How to use checksums
395c3718e8e90e975fe3ae90c4c300ddee099ff0227f4162a122148f404810d2
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 Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.6

2 release files

This release

0.1.5 This release

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