time_of_day 1.0.2
time_of_day: ^1.0.2 copied to clipboard
Type-safe Dart package for representing and manipulating time of day values with microsecond precision, supporting AM/PM periods, time comparisons, and safe arithmetic operations.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.2 - 2025-11-26 #
Added #
- Example files demonstrating package features:
basic_usage.dart- Core features and basic operationsoverflow_handling.dart- All three TimeAddOption modestime_sequences.dart- Generating time schedulespractical_examples.dart- Real-world use casesduration_extensions.dart- Duration extension featuresexample/README.md- Guide to running examples
1.0.1 - 2025-11-26 #
Added #
- Comprehensive inline documentation for all public APIs
- Library-level documentation with usage examples
1.0.0 - 2025-11-26 #
Added #
- Initial release of the
time_of_daypackage - TimeOfDay class for representing and manipulating time within a day
- Microsecond precision (0-24 hours)
- Multiple constructors:
TimeOfDay({hour, minute, second, millisecond, microsecond})- Create from componentsTimeOfDay.now()- Create from current timeTimeOfDay.fromDateTime(DateTime)- Create from DateTimeTimeOfDay.dayPeriod({periodHour, minute, ..., DayPeriod})- Create using AM/PM format
- Static constants:
midNight,noon,endOfDay - Properties:
hour,minute,second,millisecond,microsecond,period,hourOfPeriod
- Duration arithmetic with overflow handling
add(Duration, [TimeAddOption])- Add duration with three modes:TimeAddOption.throwOnOverflow- Throw error if exceeding 24:00:00 (safest)TimeAddOption.startNewDay- Wrap around to next day like a clock (default)TimeAddOption.fromMidnight- Apply duration from midnight, ignoring base time
- Time comparisons
isAfter(TimeOfDay, {bool orSameMoment})- Check if after another timeisBefore(TimeOfDay, {bool orSameMoment})- Check if before another timeisBetween(TimeOfDay, TimeOfDay, {bool includeSameMoment})- Check if between two timescompareTo(TimeOfDay)- ImplementsComparable<TimeOfDay>
- Time sequence generation
generateByDurations(TimeOfDay seed, int length, Duration duration, ...)- Generate time sequences- Support for overflow handling and automatic trimming
- DayPeriod enum - AM/PM support
DayPeriod.am- Ante meridiem (before noon)DayPeriod.pm- Post meridiem (after noon)
- Duration extensions (
duration_extensions.dart)hours- Hours within a day (0-23)minutes- Minutes within an hour (0-59)seconds- Seconds within a minute (0-59)milliseconds- Milliseconds within a second (0-999)microseconds- Microseconds within a millisecond (0-999)
- Equatable support
- Built-in equality comparison
- Hash code support for use in collections
- Comprehensive documentation
- Complete API reference in README.md
- Usage examples for all features
- Real-world examples (scheduling, time validation, shift management)
- Migration guide and best practices
- Test coverage
- Comprehensive unit tests covering all functionality
- 100% code coverage
Features #
- ๐ Microsecond precision time representation
- ๐ข Multiple constructor options for flexibility
- โ Safe arithmetic with overflow protection
- โ๏ธ Rich comparison operations
- ๐ AM/PM (12-hour) format support
- ๐ Time sequence generation
- โ Equatable and Comparable implementations
- ๐งฉ Duration extensions for convenient time calculations
- ๐ Comprehensive documentation with examples
- ๐งช Fully tested with 100% coverage
- ๐ฏ Type-safe API
- ๐ช Zero dependencies (except
equatableandclock)