duration
4.0.3, released 2 years ago by an unverified publisher
Format and parse human‑readable durations in Dart
What it does
Provides extension methods and functions to convert Duration objects to readable strings and to parse strings back into Duration. Supports locales, abbreviations, custom delimiters, and negative values.
AI-written summary of version 4.0.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- When you need to display durations in a friendly format
- When parsing duration strings from user input or configuration
Skip it when
- When you need advanced time zone or calendar calculations
- When you need to work with weeks or months as separate units
Strengths
- Rich locale support
- Customizable formatting (abbreviated, spacer, delimiter)
- Handles negative durations
- No external dependencies
Weaknesses
- No support for weeks/months in pretty output
- Limited to Duration, not full calendar dates
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
```dart
import 'package:duration/duration.dart';
final dur = Duration(days: 5, hours: 23, minutes: 59);
print(dur.pretty()); // 5d, 23h, 59m
final parsed = parseDuration('5:23:59');
print(parsed); // 0:05:23:59.000000
```Alternatives
Packages that do the same job and could replace duration.
- gtk
GTK utilities for Flutter Linux applications, providing settings and application lifecycle helpers.
76Compare - flutter_flavorizr
A utility to easily create and configure application flavors in Flutter.
86Compare - native_stack_traces
Decode non-symbolic stack traces from AOT-compiled Dart apps using stored debugging info
83Compare - moment_dart
Multi-purpose immutable DateTime subclass with support for multiple localizations and human-readable formats
66Compare