calendar_date 0.9.0
calendar_date: ^0.9.0 copied to clipboard
A Dart package for managing timezone-agnostic calendar dates.
calendar_date #
calendar_date is a dart package for creating timezone-agnostic Dates and DateTimes.
License #
This project is licensed under the MIT License.
Features #
- Immutable
CalendarDateandCalendarDateTimeclasses - Easy date arithmetic (add, subtract, difference)
- Date range iteration and stride utilities
- Comparison operators and equality
- Utilities for working with months, weeks, and days
- No external dependencies
Installation #
Add the following to your pubspec.yaml:
dependencies:
calendar_date: ^<latest_version>
Then run:
dart pub get
Usage #
Import the package:
import 'package:calendar_date/calendar_date.dart';
Creating Dates #
final date = CalendarDate(2025, 8, 4);
final today = CalendarDate.local();
final todayUtc = CalendarDate.zulu();
final today2 = CalendarDate.fromDateTime(DateTime.now());
final today2Utc = CalendarDate.fromDateTime(DateTime.timestamp());
Date Arithmetic #
final tomorrow = date + const Duration(days: 1);
final yesterday = date - const Duration(days: 1);
Date Ranges and Stride #
for (final d in date.t0(tomorrow, by: const Duration(days: 1))) {
print(d);
}
OUT:
2025-08-04
2025-08-05
Comparison #
if (date > CalendarDate(2025, 1, 1)) {
print('Date is after Jan 1, 2025');
}
Contributing #
Contributions are welcome! Please open issues or submit pull requests on GitHub.
- Fork the repository
- Create a feature branch
- Write tests for your changes
- Open a pull request