From 596a3ac667270d209ee6def8af5c50a4c43d4014 Mon Sep 17 00:00:00 2001 From: Douglas Date: Fri, 23 May 2025 16:23:04 -0300 Subject: [PATCH] feat: add time-based timer functionality with comprehensive testing - 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 --- README.md | 30 ++++ main.go | 114 ++++++++++++++- main_test.go | 385 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 522 insertions(+), 7 deletions(-) create mode 100644 main_test.go diff --git a/README.md b/README.md index fc06e2d..e4b5975 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,49 @@ with a couple of extra features: ```sh timer timer -n +timer -t