Commit graph

2 commits

Author SHA1 Message Date
999ac9a7a3 feat(quando-10t): implement human-readable duration format with i18n support
Add Duration.Human() method for localized, human-readable duration formatting:
- Adaptive granularity: displays 2 largest time units
- i18n support for EN and DE languages
- Handles singular/plural forms automatically
- Supports negative durations with minus prefix
- Zero duration special case handling

Performance: ~0.88µs/op (11x faster than 10µs target)
Coverage: 100% on diff.go, 98.2% overall

Files modified:
- diff.go: Added Human() method with fmt import
- diff_test.go: Added 18 comprehensive tests + 2 benchmarks
- example_test.go: Added 3 example functions
2026-02-11 19:42:10 +01:00
e5ece8d480 feat(quando-ljj): implement Duration type and Diff calculation
- Add Duration type with private start/end time fields
- Implement Diff(a, b) package function
- Implement integer methods (Seconds, Minutes, Hours, Days, Weeks, Months, Years)
- Implement float methods (MonthsFloat, YearsFloat) for precise calculations
- Months calculation handles month-end dates and leap years correctly
- Negative duration support (when a < b)
- Correct handling of year boundaries and leap years
- Comprehensive table-driven tests covering edge cases
- Negative duration tests
- Cross-boundary tests (year, leap year)
- Float precision tests
- Performance benchmarks (all meet targets)
- 98.6% test coverage (exceeds 95% requirement)
- Godoc comments with precision explanation

Benchmark results:
- Seconds: ~15ns (< 1µs target) ✓
- Months: ~54ns (< 1µs target) ✓
- MonthsFloat: ~172ns (< 2µs target) ✓
- Zero allocations for all operations

All acceptance criteria met:
✓ Duration type defined
✓ Diff(a, b) returns Duration
✓ All integer methods implemented (Seconds through Years)
✓ Float methods for Months and Years implemented
✓ Negative differences handled correctly
✓ Calculations correct across year boundaries
✓ Leap year handling correct
✓ Unit tests with 98.6% coverage
✓ Table-driven tests for various date ranges
✓ Benchmarks meet targets
✓ Godoc comments with precision explanation
2026-02-11 17:38:22 +01:00