Skip to content

Commit

Permalink
Merge pull request #3 from gbassisp/feature/locale_aware_rules
Browse files Browse the repository at this point in the history
add support for intl 0.19
  • Loading branch information
gbassisp authored Apr 15, 2024
2 parents af78ae0 + 6377acb commit 0044935
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

## 1.0.1

- Added support for `intl` 0.19

## 1.0.0

Stable version release
Expand Down
2 changes: 2 additions & 0 deletions lib/src/any_date_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ const _shortMonths = [
Month(number: 5, name: 'May'),
Month(number: 6, name: 'Jun'),
Month(number: 7, name: 'Jul'),
Month(number: 6, name: 'June'),
Month(number: 7, name: 'July'),
Month(number: 8, name: 'Aug'),
Month(number: 9, name: 'Sep'),
Month(number: 9, name: 'Sept'),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: any_date
description: A package for parsing String into DateTime in any format. Supports any formats in any language while always respecting ISO and RFC formats.
version: 1.0.0
version: 1.0.1
repository: https://github.com/gbassisp/any_date
homepage: https://github.com/gbassisp/any_date

environment:
sdk: '>=2.12.0 <4.0.0'

dependencies:
intl: ^0.18.1
intl: ">=0.18.1 <0.20.0"
meta: ^1.0.0

dev_dependencies:
Expand Down
4 changes: 2 additions & 2 deletions test/any_date_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void testRange(
}

extension _TryParse on DateFormat {
DateTime? tryParse(String input) {
DateTime? _tryParse(String input) {
try {
return parse(input);
} catch (_) {
Expand All @@ -85,7 +85,7 @@ void compare(DateFormat format, AnyDate anyDate, {bool randomDates = true}) {
final d = f.format(singleDate);
final a = anyDate;
final config = a.info;
final e = f.tryParse(d);
final e = f._tryParse(d);
// expect(e, isNotNull, reason: 'DateFormat failed: $reason');
final r = a.tryParse(d);
final reason = 'format: ${format.pattern}\n '
Expand Down
18 changes: 9 additions & 9 deletions test/locale_based_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,24 @@ Future<void> main() async {

expect(locale.usesMonthFirst, isTrue);
expect(locale.usesYearFirst, isFalse);
expect(locale.longMonths, containsAllInOrder(longMonths));
expect(locale.shortMonths, containsAllInOrder(shortMonths));
expect(locale.longWeekdays, containsAllInOrder(longWeekdays));
expect(locale.shortWeekdays, containsAllInOrder(shortWeekdays));
expect(longMonths, containsAll(locale.longMonths));
expect(shortMonths, containsAll(locale.shortMonths));
expect(longWeekdays, containsAll(locale.longWeekdays));
expect(shortWeekdays, containsAll(locale.shortWeekdays));
});

test('english speaking - normal format', () {
final locale = Locale.fromSubtags(languageCode: 'en', countryCode: 'AU');
final longMonths = englishMonths.sublist(0, 12);
final shortMorhts = englishMonths.sublist(12)
final shortMonths = englishMonths.sublist(12)
..removeWhere((element) => element.name == 'Sep');

expect(locale.usesMonthFirst, isFalse);
expect(locale.usesYearFirst, isFalse);
expect(locale.longMonths, containsAllInOrder(longMonths));
expect(locale.shortMonths, containsAllInOrder(shortMorhts));
expect(locale.longWeekdays, containsAllInOrder(longWeekdays));
expect(locale.shortWeekdays, containsAllInOrder(shortWeekdays));
expect(longMonths, containsAll(locale.longMonths));
expect(shortMonths, containsAll(locale.shortMonths));
expect(longWeekdays, containsAll(locale.longWeekdays));
expect(shortWeekdays, containsAll(locale.shortWeekdays));
});
});

Expand Down

0 comments on commit 0044935

Please sign in to comment.