date_time
0.12.0, released 2 years ago by devcraft.ninja
Provides Date, Time, and range classes with comparison and manipulation utilities.
What it does
The package defines separate Date and Time objects, supports copying, arithmetic, and overflow handling, and includes DateRange and TimeRange types for interval operations. It also offers extensions on DateTime and integrates with the clock package for testable time sources.
AI-written summary of version 0.12.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need strong typed date or time handling beyond DateTime
- You work with booking or scheduling logic requiring ranges and overflow logic
Skip it when
- You only need simple DateTime usage without extra types
- You require timezone-aware or locale‑specific date handling beyond what intl provides
Strengths
- Clear separation of date and time concepts
- Range and overflow support out of the box
- CopyWith and immutable‑style API
Weaknesses
- No built‑in timezone or locale‑aware parsing beyond intl
- Limited ecosystem compared to more mature date libraries
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 4
import 'package:date_time/date_time.dart';
void main(){
final date = Date(year:2022, month:5, day:10);
final time = Time(hour:14, minute:30);
final range = DateRange(date, date.addDays(5));
print(range.isValid); // true
}Alternatives
Packages that do the same job and could replace date_time.
- simple_date
A simple date model for Dart with no notion of time.
56Compare - tempo
A time and date solution replacing core DateTime with advanced arithmetic and time zone support.
71Compare - time_plus
Extensions for DateTime and Duration to easily add, convert, and work with time in Dart.
51Compare - jiffy
Parse, manipulate, query, and format dates and times in Dart and Flutter.
70Compare
Works with
Packages commonly used together with date_time: ones it builds on, ones built on it, and its own family.
- clockdate_time depends on itA fakeable wrapper for dart:core clock APIs.
- json_annotationdate_time depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- intldate_time depends on itA Dart library for internationalization and localization, providing message translation, plural/gender handling, and date/number formatting.
- quiverdate_time depends on itA set of utility libraries for Dart containing collections, async tools, and testing helpers.