Skip to content

Add time unit support for date filters#130

Merged
holmboe merged 1 commit intomasterfrom
feature/time-unit-support-issue-105
Feb 23, 2026
Merged

Add time unit support for date filters#130
holmboe merged 1 commit intomasterfrom
feature/time-unit-support-issue-105

Conversation

@holmboe
Copy link
Contributor

@holmboe holmboe commented Feb 20, 2026

Summary

Adds support for time units (h, d, w, m, y) to date filter flags, addressing #105.

Changes

Core Implementation

  • New function: parse_time_with_unit() in phabfive/maniphest.py to parse time values with optional unit suffixes
  • Updated: task_search() method to use the parser for all four date parameters:
    • --created-after
    • --created-before
    • --updated-after
    • --updated-before
  • Improved display: Output now shows original time values with units (e.g., created-after=1w instead of created-after=7d)

Supported Time Units

Unit Description Example
h Hours 12h = 12 hours
d Days 7d = 7 days
w Weeks 2w = 14 days
m Months 1m ≈ 30 days
y Years 1y ≈ 365 days

Note: Plain numbers (e.g., 7) continue to work as days for backward compatibility.

Testing

  • ✅ Added 17 comprehensive tests covering:
    • All time units (h, d, w, m, y)
    • Backward compatibility with plain numbers
    • Error handling for invalid inputs
    • Edge cases (zero, negative, whitespace, case sensitivity)
  • ✅ All 115 tests pass

Documentation

  • Updated CLI help text with time unit syntax
  • Updated docs/maniphest-cli.md with comprehensive examples
  • Updated docs/search-templates.md with YAML template examples
  • Updated README.md examples

Example Usage

# Before (only days)
phabfive maniphest search --tag Backend --updated-after=7

# After (with time units)
phabfive maniphest search --tag Backend --updated-after=1w
phabfive maniphest search --tag Project --created-after=2m --updated-after=1w
phabfive maniphest search --tag Team --updated-after=12h

YAML Template Example

search:
  tag: "My Project"
  created-after: "1w"   # or use plain numbers: 7
  updated-before: "2w"

Benefits

  • 🎯 No mental math needed to convert weeks/months/years to days
  • 🔄 Fully backward compatible with existing scripts
  • 📝 Clear, user-friendly syntax
  • ✅ Comprehensive error messages for invalid formats
  • 🧪 Well-tested with 100% test coverage

Fixes

Closes #105

🤖 Generated with Claude Code

This adds support for time units (h, d, w, m, y) to all date filter flags:
--created-after, --created-before, --updated-after, --updated-before

Changes:
- Add parse_time_with_unit() function to parse time values with units
- Update task_search() to use new parser for all date parameters
- Display output now shows original time values (e.g., "1w" not "7d")
- Add comprehensive test suite (17 new tests, all passing)
- Update CLI help text and examples
- Update all documentation with time unit syntax and examples

Supported time units:
- h: hours (e.g., 12h)
- d: days (e.g., 7d)
- w: weeks (e.g., 2w = 14 days)
- m: months (e.g., 1m ≈ 30 days)
- y: years (e.g., 1y ≈ 365 days)

Backward compatible: plain numbers still work as days.

Example usage:
  phabfive maniphest search --tag Backend --updated-after=1w
  phabfive maniphest search --tag Project --created-after=2m
  phabfive maniphest search --tag Team --updated-after=12h

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@holmboe holmboe requested a review from Timpan4 February 20, 2026 19:31
Copy link
Contributor

@Timpan4 Timpan4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Really nice QOL improvement

@holmboe holmboe merged commit b2cdda3 into master Feb 23, 2026
15 checks passed
@holmboe holmboe deleted the feature/time-unit-support-issue-105 branch February 23, 2026 12:46
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.

Time selectors should support time units

2 participants