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.
Examples #
This directory contains practical examples demonstrating the time_of_day package features.
Available Examples #
1. basic_usage.dart #
Introduction to core features:
- Creating
TimeOfDayinstances - Using predefined constants
- Accessing time components
- Basic arithmetic and comparisons
Run: dart run example/basic_usage.dart
2. overflow_handling.dart #
Demonstrates the three overflow modes:
startNewDay- Wraps around like a clock (default)throwOnOverflow- Throws exception for safetyfromMidnight- Applies duration from midnight
Run: dart run example/overflow_handling.dart
3. time_sequences.dart #
Generating time sequences:
- Hourly schedules
- Custom interval sequences
- Wrap-around behavior
- Auto-trimming at day boundaries
Run: dart run example/time_sequences.dart
4. practical_examples.dart #
Real-world use cases:
- Business hours validation
- Appointment scheduling
- Time until next event
- Lunch break validation
- Shift rotation
Run: dart run example/practical_examples.dart
5. duration_extensions.dart #
Working with duration extensions:
- Normalizing overflow durations
- Extracting time components
- Microsecond precision
- Multiple day durations
Run: dart run example/duration_extensions.dart
Running All Examples #
To run all examples at once:
for file in example/*.dart; do
echo "Running $file..."
dart run "$file"
echo ""
done