time
2.1.6, released 11 months ago by jogboms.xyz
Type-safe DateTime and Duration calculations, powered by extensions.
What it does
Provides convenient Dart extensions for DateTime and Duration objects. Allows writing expressive time-based calculations like `10.minutes` or `5.minutes.fromNow` and adds helpers for comparison, ranges, and `copyWith`.
AI-written summary of version 2.1.6, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want readable and expressive time and duration math in your Dart or Flutter project.
- You frequently need to add or subtract time using intuitive syntax.
Skip it when
- You require robust, localized date formatting and parsing (use intl instead).
Strengths
- Extremely clean and readable syntax inspired by Swift and Kotlin.
- Zero boilerplate with no code generation required.
Weaknesses
- Relies on global extensions which might pollute auto-complete if not desired.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Simply add to pubspec.yaml and import 'package:time/time.dart'.
final Duration tenMinutes = 10.minutes;
final DateTime tenMinutesFromNow = 10.minutes.fromNow;Alternatives
Packages that do the same job and could replace time.
- pubspec_parse
Parse pubspec.yaml files with a type‑safe API and detailed error reporting.
93Compare - mime
Utilities to resolve MIME types from file names, magic bytes, and to parse multipart streams.
92Compare - deep_pick
Type-safe API for manual JSON parsing with useful error messages.
91Compare - dart_either
Either monad for Dart and Flutter supporting type-safe error handling and railway-oriented programming.
81Compare
Works with
Packages commonly used together with time: ones it builds on, ones built on it, and its own family.