From 7ee63f5f13f0c0298f235b1200c8ac2acddd302e Mon Sep 17 00:00:00 2001 From: Craig Hathaway Date: Tue, 7 Jan 2025 22:18:30 -0500 Subject: [PATCH] improve name --- CHANGELOG.md | 2 +- lib/datetime/date_time_range_utils.dart | 2 +- pubspec.yaml | 2 +- test/datetime/date_time_range_utils_test.dart | 52 +++++++++---------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c6be67..4a9bfe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ Learn more at https://saropa.com, or email dev.tools@saropa.com **** -## 0.3.17+Kyoto (Latest) +## 0.3.18+Kyoto (Latest) * ⏰ Added boilerplate [DateTimeRange] utils * ⏰ Added many useful boilerplate [DateTime] utils diff --git a/lib/datetime/date_time_range_utils.dart b/lib/datetime/date_time_range_utils.dart index b2cbdbc..7d3a8bd 100644 --- a/lib/datetime/date_time_range_utils.dart +++ b/lib/datetime/date_time_range_utils.dart @@ -6,7 +6,7 @@ extension DateTimeRangeExtensions on DateTimeRange { /// Determines if the nth occurrence of a specific day of the week in a given /// month falls within the specified date range. /// - bool isNthDayOfMonth( + bool isNthDayOfMonthInRange( int n, int dayOfWeek, int month, { diff --git a/pubspec.yaml b/pubspec.yaml index d8bdb61..1bd6cf1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: saropa_dart_utils description: "Boilerplate reduction tools and human-readable extension methods by Saropa" -version: 0.3.17 +version: 0.3.18+Kyoto homepage: https://app.saropa.com repository: https://github.com/saropa/saropa_dart_utils diff --git a/test/datetime/date_time_range_utils_test.dart b/test/datetime/date_time_range_utils_test.dart index 8b957e1..2252b1f 100644 --- a/test/datetime/date_time_range_utils_test.dart +++ b/test/datetime/date_time_range_utils_test.dart @@ -9,7 +9,7 @@ void main() { start: DateTime(2023), end: DateTime(2023, 12, 31), ); - expect(range.isNthDayOfMonth(2, DateTime.monday, 3), true); + expect(range.isNthDayOfMonthInRange(2, DateTime.monday, 3), true); }); test('returns false for 2nd Monday of March outside range', () { @@ -17,7 +17,7 @@ void main() { start: DateTime(2023, 4), end: DateTime(2023, 12, 31), ); - expect(range.isNthDayOfMonth(2, DateTime.monday, 3), false); + expect(range.isNthDayOfMonthInRange(2, DateTime.monday, 3), false); }); test('returns true for 1st Friday of January at start of range', () { @@ -25,7 +25,7 @@ void main() { start: DateTime(2023), end: DateTime(2023, 12, 31), ); - expect(range.isNthDayOfMonth(1, DateTime.friday, 1), true); + expect(range.isNthDayOfMonthInRange(1, DateTime.friday, 1), true); }); test('returns true for last day of range', () { @@ -33,7 +33,7 @@ void main() { start: DateTime(2023), end: DateTime(2023, 12, 31), ); - expect(range.isNthDayOfMonth(5, DateTime.sunday, 12), true); + expect(range.isNthDayOfMonthInRange(5, DateTime.sunday, 12), true); }); test('returns false for day just after range', () { @@ -41,7 +41,7 @@ void main() { start: DateTime(2023), end: DateTime(2023, 12, 30), ); - expect(range.isNthDayOfMonth(5, DateTime.sunday, 12), false); + expect(range.isNthDayOfMonthInRange(5, DateTime.sunday, 12), false); }); test('returns true for recurring holiday across multiple years', () { @@ -49,7 +49,7 @@ void main() { start: DateTime(2022), end: DateTime(2024, 12, 31), ); - expect(range.isNthDayOfMonth(3, DateTime.monday, 1), true); + expect(range.isNthDayOfMonthInRange(3, DateTime.monday, 1), true); }); test('returns false when nth occurrence does not exist', () { @@ -58,7 +58,7 @@ void main() { end: DateTime(2023, 12, 31), ); expect( - range.isNthDayOfMonth(5, DateTime.monday, 2), + range.isNthDayOfMonthInRange(5, DateTime.monday, 2), false, ); // February never has 5 Mondays }); @@ -69,7 +69,7 @@ void main() { end: DateTime(2024, 12, 31), ); expect( - range.isNthDayOfMonth(5, DateTime.thursday, 2), + range.isNthDayOfMonthInRange(5, DateTime.thursday, 2), true, ); // February 29, 2024 }); @@ -80,7 +80,7 @@ void main() { end: DateTime(2023, 12, 31), ); expect( - range.isNthDayOfMonth(5, DateTime.thursday, 2), + range.isNthDayOfMonthInRange(5, DateTime.thursday, 2), false, ); // February 29, 2024 not in 2023 }); @@ -88,32 +88,32 @@ void main() { test('returns true for 1st Monday of January in multi-year range', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2025, 12, 31)); - expect(range.isNthDayOfMonth(1, DateTime.monday, 1), true); + expect(range.isNthDayOfMonthInRange(1, DateTime.monday, 1), true); }); test('returns false for 6th Friday of April (impossible case)', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2023, 12, 31)); - expect(range.isNthDayOfMonth(6, DateTime.friday, 4), false); + expect(range.isNthDayOfMonthInRange(6, DateTime.friday, 4), false); }); test('returns true for 5th Wednesday of May 2023 (May 31, 2023)', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2023, 12, 31)); - expect(range.isNthDayOfMonth(5, DateTime.wednesday, 5), true); + expect(range.isNthDayOfMonthInRange(5, DateTime.wednesday, 5), true); }); test('returns false for 5th Wednesday of May 2024', () { final range = DateTimeRange(start: DateTime(2024), end: DateTime(2024, 12, 31)); - expect(range.isNthDayOfMonth(5, DateTime.wednesday, 5), true); + expect(range.isNthDayOfMonthInRange(5, DateTime.wednesday, 5), true); }); test('returns true for 4th Thursday of November (Thanksgiving) in 2023', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2023, 12, 31)); - expect(range.isNthDayOfMonth(4, DateTime.thursday, 11), true); + expect(range.isNthDayOfMonthInRange(4, DateTime.thursday, 11), true); }); test( @@ -121,19 +121,19 @@ void main() { 'ending before November', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2023, 10, 31)); - expect(range.isNthDayOfMonth(4, DateTime.thursday, 11), false); + expect(range.isNthDayOfMonthInRange(4, DateTime.thursday, 11), false); }); test('returns true for 1st Sunday of February in leap year 2024', () { final range = DateTimeRange(start: DateTime(2024), end: DateTime(2024, 12, 31)); - expect(range.isNthDayOfMonth(1, DateTime.sunday, 2), true); + expect(range.isNthDayOfMonthInRange(1, DateTime.sunday, 2), true); }); test('returns false for 5th Saturday of December 2023', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2023, 12, 31)); - expect(range.isNthDayOfMonth(5, DateTime.saturday, 12), true); + expect(range.isNthDayOfMonthInRange(5, DateTime.saturday, 12), true); }); test( @@ -141,7 +141,7 @@ void main() { 'including multiple years', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2025, 12, 31)); - expect(range.isNthDayOfMonth(2, DateTime.tuesday, 2), true); + expect(range.isNthDayOfMonthInRange(2, DateTime.tuesday, 2), true); }); test('returns false when nth occurrence does not exist', () { @@ -150,7 +150,7 @@ void main() { end: DateTime(2023, 12, 31), ); expect( - range.isNthDayOfMonth(5, DateTime.monday, 2), + range.isNthDayOfMonthInRange(5, DateTime.monday, 2), false, ); // February never has 5 Mondays }); @@ -158,32 +158,32 @@ void main() { test('returns false for 6th Friday of April (impossible case)', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2023, 12, 31)); - expect(range.isNthDayOfMonth(6, DateTime.friday, 4), false); + expect(range.isNthDayOfMonthInRange(6, DateTime.friday, 4), false); }); test('returns false for 5th Wednesday of May 2024', () { final range = DateTimeRange(start: DateTime(2024), end: DateTime(2024, 12, 31)); - expect(range.isNthDayOfMonth(5, DateTime.wednesday, 5), true); + expect(range.isNthDayOfMonthInRange(5, DateTime.wednesday, 5), true); }); test('returns true for 5th Saturday of December 2024 (does not exist)', () { final range = DateTimeRange(start: DateTime(2024), end: DateTime(2024, 12, 31)); - expect(range.isNthDayOfMonth(5, DateTime.saturday, 12), false); + expect(range.isNthDayOfMonthInRange(5, DateTime.saturday, 12), false); }); test('returns true for 1st Monday of January in multi-year range', () { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2025, 12, 31)); - expect(range.isNthDayOfMonth(1, DateTime.monday, 1), true); + expect(range.isNthDayOfMonthInRange(1, DateTime.monday, 1), true); }); test('returns true for February 29 in leap year', () { final range = DateTimeRange(start: DateTime(2024), end: DateTime(2024, 12, 31)); expect( - range.isNthDayOfMonth(1, DateTime.thursday, 2), + range.isNthDayOfMonthInRange(1, DateTime.thursday, 2), true, ); // February has a Thursday on Feb.29 }); @@ -193,7 +193,7 @@ void main() { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2023, 12, 31)); expect( - range.isNthDayOfMonth(5, DateTime.monday, 2), + range.isNthDayOfMonthInRange(5, DateTime.monday, 2), false, ); // February never has a fifth Monday }); @@ -202,7 +202,7 @@ void main() { final range = DateTimeRange(start: DateTime(2023), end: DateTime(2023, 12, 31)); expect( - range.isNthDayOfMonth(5, DateTime.sunday, 12), + range.isNthDayOfMonthInRange(5, DateTime.sunday, 12), true, ); // December has a Sunday on Dec.31 });