Skip to content

Expiration date support#73

Open
steigr wants to merge 2 commits into
Evidlo:masterfrom
steigr:feature/expiration-date-support
Open

Expiration date support#73
steigr wants to merge 2 commits into
Evidlo:masterfrom
steigr:feature/expiration-date-support

Conversation

@steigr

@steigr steigr commented Jan 14, 2026

Copy link
Copy Markdown

Add Entry Expiration Date Support

Summary

This PR adds support for entry expiration dates, allowing to set, view, edit, and track expiring passwords.

Features

New Command expired

  • expired - List expired or expiring entries
    • ph expired - Show all expired entries
    • ph expired --days 30 - Show expired entries and those expiring within 30 days

Updates to existing commands

  • show - Now displays expiration date

    • Shows "Expires: Never" for non-expiring entries
    • Shows expiration date with (EXPIRED) in red for expired entries
    • Shows expiration date with (expiring soon) in yellow for entries expiring within 30 days
    • New --expiry flag to show only the expiration date
  • add - New --expires option to set expiration when creating entries

    ph add myentry --expires "+30d"      # Expires in 30 days
    ph add myentry --expires "2026-12-31" # Expires on specific date
  • edit - New --expires option to modify expiration date

    ph edit myentry --expires "+60d"     # Change to 60 days from now
    ph edit myentry --expires "never"    # Disable expiration

Supported Date Formats

  • ISO date: 2026-12-31
  • ISO datetime: 2026-12-31T23:59:59
  • Relative days: +30d
  • Relative weeks: +2w
  • Relative months: +6m
  • Relative years: +1y
  • Disable: never

Technical Details

pykeepass-cache Compatibility

This PR includes fixes for compatibility with pykeepass-cache:

  • ensure_timezone_aware() - New helper function that converts rpyc netref datetime objects to local datetime objects, fixing comparison issues between remote and local datetime instances

  • set_entry_expiry() - New helper function that properly encodes datetime values when setting expiration on cached entries by:

    • Detecting rpyc netref entries
    • Encoding datetime in pykeepass's expected format (base64-encoded seconds since 0001-01-01)
    • Setting the value directly via XML element manipulation

Bug Fixes

  • Fixed invalid escape sequence warning in symbolic character set
  • Fixed datetime comparison errors when using pykeepass-cache

Usage Examples

# Add entry with 90-day expiration
ph add work/server-password --expires "+90d" -a 32

# Check for expiring entries
ph expired --days 30

# View entry with expiration info
ph show work/server-password

# Extend expiration by another year
ph edit work/server-password --expires "+1y"

# Remove expiration
ph edit work/server-password --expires "never"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant