From ba9b0b2142184f251d6c42718bf33662f8e879c2 Mon Sep 17 00:00:00 2001 From: Sharjeel Yunus Date: Wed, 9 Jul 2025 18:30:21 +0500 Subject: [PATCH 1/3] Update intl dependency version in pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 8e744a6..5cb9748 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - intl: ">=0.18.1 <=0.19.0" + intl: ">=0.18.1 <=0.20.2" timeago: ^3.0.2 dev_dependencies: From 9be084c38d6eb9ca3588535cbf21d5aed67051e0 Mon Sep 17 00:00:00 2001 From: Sharjeel Yunus Date: Wed, 9 Jul 2025 18:48:44 +0500 Subject: [PATCH 2/3] Release 1.6.0: Rename package to ensemble_date, update dependencies, add analysis options, and improve documentation. This version is a maintained fork of dart_date with enhanced features and compatibility. --- CHANGELOG.md | 8 ++++++++ LICENSE | 1 + README.md | 27 +++++++++++++++++++++++---- analysis_options.yaml | 25 +++++++++++++++++++++++++ example/dart_date_example.dart | 2 +- lib/dart_date.dart | 3 --- lib/ensemble_date.dart | 4 ++++ lib/src/dart_date.dart | 19 ++++++++++++------- pubspec.yaml | 15 +++++++++------ test/dart_date_test.dart | 2 +- 10 files changed, 84 insertions(+), 22 deletions(-) create mode 100644 analysis_options.yaml delete mode 100644 lib/dart_date.dart create mode 100644 lib/ensemble_date.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 16fc792..a5e2a25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 1.6.0 + +- **Fork Release**: Published as `ensemble_date` - a maintained fork of `dart_date` +- Updated package name from `dart_date` to `ensemble_date` +- Updated repository links and documentation +- Improved dependency constraints +- Enhanced pub.dev compatibility + ## 1.1.1 - Merge [PR](https://github.com/xantiagoma/dart_date/pull/16) to fix week calculation diff --git a/LICENSE b/LICENSE index d7c2910..ca2fd74 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2020 Santiago Montoya Angarita (@xantiagoma) +Copyright (c) 2024 EnsembleUI (https://github.com/EnsembleUI) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index aef67b2..979e987 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,28 @@ -# dart_date +# ensemble_date -Dart Extensions for `DartTime` +Dart Extensions for `DateTime` -dart_date provides the most comprehensive, yet simple and consistent toolset for manipulating Dart dates. +ensemble_date provides the most comprehensive, yet simple and consistent toolset for manipulating Dart dates. + +**This package is a maintained fork of [dart_date](https://pub.dev/packages/dart_date), providing continued updates and improvements.** Inspired by [date-fns](https://date-fns.org/) +## Installation + +Add this to your package's `pubspec.yaml` file: + +```yaml +dependencies: + ensemble_date: ^1.6.0 +``` + +Then run: + +```bash +dart pub get +``` + ## Usage - Use `instance.method()` for added methods. @@ -27,6 +44,8 @@ Tomorrow: 2020-06-19 08:33:52.700579 ``` ```dart +import 'package:ensemble_date/ensemble_date.dart'; + const pattern = '\'Heute ist\' dd-MMMM-yyyy'; final n = DateTime.now(); final de_String = DateTime.now().format(pattern, 'de_DE'); @@ -74,7 +93,7 @@ Tomorrow: 2020-06-19 08:33:52.700579 ## API -[Check full docs](https://pub.dev/documentation/dart_date/latest/) +[Check full docs](https://pub.dev/documentation/ensemble_date/latest/) Date extension on DateTime diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..ae4ee37 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,25 @@ +include: package:lints/recommended.yaml + +analyzer: + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" + +linter: + rules: + # Disable rules that conflict with existing code patterns + prefer_relative_imports: false + avoid_dynamic_calls: false + comment_references: false + constant_identifier_names: false + unnecessary_brace_in_string_interps: false + + # Keep essential rules + avoid_slow_async_io: true + cancel_subscriptions: true + close_sinks: true + literal_only_boolean_expressions: true + no_adjacent_strings_in_list: true + test_types_in_equals: true + throw_in_finally: true + unnecessary_statements: true \ No newline at end of file diff --git a/example/dart_date_example.dart b/example/dart_date_example.dart index ff843b2..e7af600 100644 --- a/example/dart_date_example.dart +++ b/example/dart_date_example.dart @@ -1,4 +1,4 @@ -import 'package:dart_date/dart_date.dart'; +import 'package:ensemble_date/ensemble_date.dart'; main(List args) { const pattern = '\'Heute ist\' dd-MMMM-yyyy'; diff --git a/lib/dart_date.dart b/lib/dart_date.dart deleted file mode 100644 index 6aa5b8c..0000000 --- a/lib/dart_date.dart +++ /dev/null @@ -1,3 +0,0 @@ -library dart_date; - -export 'src/dart_date.dart'; diff --git a/lib/ensemble_date.dart b/lib/ensemble_date.dart new file mode 100644 index 0000000..9216a15 --- /dev/null +++ b/lib/ensemble_date.dart @@ -0,0 +1,4 @@ +/// Date manipulation library. DateTime extensions. Also includes an Interval object. +library ensemble_date; + +export 'src/dart_date.dart'; diff --git a/lib/src/dart_date.dart b/lib/src/dart_date.dart index 5400bdc..423b277 100644 --- a/lib/src/dart_date.dart +++ b/lib/src/dart_date.dart @@ -559,7 +559,12 @@ extension Date on DateTime { static bool isDate(argument) => argument is DateTime; /// Check if a date is [equals] to other - bool isEqual(other) => equals(other); + bool isEqual(dynamic other) { + if (other is DateTime) { + return equals(other); + } + return false; + } /// Return true if this date day is monday bool get isMonday => weekday == DateTime.monday; @@ -923,25 +928,25 @@ extension Date on DateTime { DateTime subDays(int amount) => addDays(-amount); /// Subtracts an amout of milliseconds from this [DateTime] - DateTime subMilliseconds(amount) => addMilliseconds(-amount); + DateTime subMilliseconds(int amount) => addMilliseconds(-amount); /// Subtracts an amout of microseconds from this [DateTime] - DateTime subMicroseconds(amount) => addMicroseconds(-amount); + DateTime subMicroseconds(int amount) => addMicroseconds(-amount); // DateTime subISOYears(amount) /// Subtracts an amout of minutes from this [DateTime] - DateTime subMinutes(amount) => addMinutes(-amount); + DateTime subMinutes(int amount) => addMinutes(-amount); /// Subtracts an amout of months from this [DateTime] - DateTime subMonths(amount) => addMonths(-amount); + DateTime subMonths(int amount) => addMonths(-amount); // DateTime subQuarters(amount) /// Subtracts an amout of seconds from this [DateTime] - DateTime subSeconds(amount) => addSeconds(-amount); + DateTime subSeconds(int amount) => addSeconds(-amount); // DateTime subWeeks(amount) /// Subtracts an amout of years from this [DateTime] - DateTime subYears(amount) => addYears(-amount); + DateTime subYears(int amount) => addYears(-amount); // Check if two dates are [equals] bool equals(DateTime other) => isAtSameMomentAs(other); diff --git a/pubspec.yaml b/pubspec.yaml index 5cb9748..15b4ee8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,14 +1,17 @@ -name: dart_date -description: Date manipulation library. DateTime extensions. Also includes an Interval object. -version: 1.1.1 -homepage: https://github.com/xantiagoma/dart_date +name: ensemble_date +description: Date manipulation library. DateTime extensions. Also includes an Interval object. Forked from dart_date with additional improvements and maintenance. +version: 1.6.0 +homepage: https://github.com/EnsembleUI/dart_date +repository: https://github.com/EnsembleUI/dart_date +issue_tracker: https://github.com/EnsembleUI/dart_date/issues environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: - intl: ">=0.18.1 <=0.20.2" + intl: ">=0.18.1 <0.21.0" timeago: ^3.0.2 dev_dependencies: test: ^1.16.0 + lints: ^3.0.0 diff --git a/test/dart_date_test.dart b/test/dart_date_test.dart index f1eb7e4..2dbe68f 100644 --- a/test/dart_date_test.dart +++ b/test/dart_date_test.dart @@ -1,4 +1,4 @@ -import 'package:dart_date/dart_date.dart'; +import 'package:ensemble_date/ensemble_date.dart'; import 'package:test/test.dart'; void main() { From 46e1e83e18e15f33c19e24c9c4dbdf83029c3fab Mon Sep 17 00:00:00 2001 From: Sharjeel Yunus Date: Thu, 10 Jul 2025 14:34:13 +0500 Subject: [PATCH 3/3] Release 1.6.1: Add new date manipulation methods including `equals`, `operator -`, and `operator +`, and update changelog and version number. --- CHANGELOG.md | 7 +++++++ lib/src/dart_date.dart | 13 ++++++++++++- pubspec.yaml | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5e2a25..6c4f258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.6.1 + +- Add `equals` method to check if two dates are equal +- Add `operator -` to subtract a duration from a date +- Add `operator +` to add a duration to a date + + ## 1.6.0 - **Fork Release**: Published as `ensemble_date` - a maintained fork of `dart_date` diff --git a/lib/src/dart_date.dart b/lib/src/dart_date.dart index 423b277..21d950b 100644 --- a/lib/src/dart_date.dart +++ b/lib/src/dart_date.dart @@ -167,6 +167,9 @@ extension Date on DateTime { /// Get [Date] object in LocalTime of current object. DateTime get toLocalTime => toLocal(); + /// Creates a new [DateTime] instance with the same value as this one + /// + /// Returns an exact copy of this [DateTime] preserving the isUtc flag and all time components. DateTime get clone => DateTime.fromMicrosecondsSinceEpoch( microsecondsSinceEpoch, isUtc: isUtc, @@ -948,7 +951,9 @@ extension Date on DateTime { /// Subtracts an amout of years from this [DateTime] DateTime subYears(int amount) => addYears(-amount); - // Check if two dates are [equals] + /// Check if two dates are equal to each other + /// + /// Returns true if this [DateTime] represents exactly the same moment in time as [other]. bool equals(DateTime other) => isAtSameMomentAs(other); bool operator <(DateTime other) => isBefore(other); @@ -1095,10 +1100,16 @@ extension Date on DateTime { isUtc: false, ); + /// Subtract a [Duration] from this [DateTime] + /// + /// Returns a new [DateTime] representing the moment that is [other] duration before this [DateTime]. DateTime operator -(Duration other) { return this.subtract(other); } + /// Add a [Duration] to this [DateTime] + /// + /// Returns a new [DateTime] representing the moment that is [other] duration after this [DateTime]. DateTime operator +(Duration other) { return add(other); } diff --git a/pubspec.yaml b/pubspec.yaml index 15b4ee8..8446ce7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: ensemble_date description: Date manipulation library. DateTime extensions. Also includes an Interval object. Forked from dart_date with additional improvements and maintenance. -version: 1.6.0 +version: 1.6.1 homepage: https://github.com/EnsembleUI/dart_date repository: https://github.com/EnsembleUI/dart_date issue_tracker: https://github.com/EnsembleUI/dart_date/issues