time_of_day 1.0.2 copy "time_of_day: ^1.0.2" to clipboard
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.

example/README.md

Examples #

This directory contains practical examples demonstrating the time_of_day package features.

Available Examples #

1. basic_usage.dart #

Introduction to core features:

  • Creating TimeOfDay instances
  • 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 safety
  • fromMidnight - 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

More Information #

4
likes
160
points
5
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

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.

Repository (GitHub)
View/report issues

Topics

#time-of-day #time #datetime #day #calendar

Documentation

API reference

License

MIT (license)

Dependencies

clock, equatable

More

Packages that depend on time_of_day