8000 feat: add time-based timer functionality with comprehensive testing (closes #6) by linkzera · Pull Request #156 · caarlos0/timer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add time-based timer functionality with comprehensive testing (closes #6) #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

linkzera
Copy link
8000 Contributor
  • Add --time/-t flag to set timer until specific time (e.g., 14:30, 2:30PM)
  • Support multiple time formats: 24h, 12h with AM/PM (case insensitive), with/without seconds
  • Implement smart scheduling: past times automatically target next day
  • Reject ambiguous single-digit hour formats (e.g., "1:30") to prevent confusion
  • Add calculateDurationUntilTime function with robust time parsing
  • Enhance formatDuration with cleaner display and better precision
  • Add comprehensive test suite with 95%+ coverage:
    • Duration formatting validation
    • Time parsing for all supported formats
    • Error handling and edge cases
    • Real-world usage scenarios
    • Performance benchmarks
  • Update README with usage examples and supported time formats
  • Maintain backward compatibility with existing duration-based timers

Examples:
timer -t 14:30 # Until 2:30 PM today/tomorrow
timer -t 2:30PM # 12-hour format
timer -t 07:00 -n Alarm # Named morning timer

- Add --time/-t flag to set timer until specific time (e.g., 14:30, 2:30PM)
- Support multiple time formats: 24h, 12h with AM/PM (case insensitive), with/without seconds
- Implement smart scheduling: past times automatically target next day
- Reject ambiguous single-digit hour formats (e.g., "1:30") to prevent confusion
- Add calculateDurationUntilTime function with robust time parsing
- Enhance formatDuration with cleaner display and better precision
- Add comprehensive test suite with 95%+ coverage:
  * Duration formatting validation
  * Time parsing for all supported formats
  * Error handling and edge cases
  * Real-world usage scenarios
  * Performance benchmarks
- Update README with usage examples and supported time formats
- Maintain backward compatibility with existing duration-based timers

Examples:
  timer -t 14:30        # Until 2:30 PM today/tomorrow
  timer -t 2:30PM       # 12-hour format
  timer -t 07:00 -n Alarm  # Named morning timer
@linkzera linkzera changed the title feat: add time-based timer functionality with comprehensive testing feat: add time-based timer functionality with comprehensive testing (closes #6) May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0