Skip to content

Commit

Permalink
Add README example for isAtSame extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
matuella authored and jogboms committed Mar 5, 2021
1 parent bc6747d commit c444037
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ final DateTime end = start + 1.weeks;
final DateTime tuesday = start.to(end).firstWhere((date) => date.weekday == DateTime.tuesday);
```

Granular comparison between `DateTime` fields:

```dart
final DateTime specificDate = DateTime(2021, 01, 01);
final DateTime otherDate = DateTime(2021, 02, 01);
print(specificDate.isAtSameYearAs(otherDate)); // true
print(specificDate.isAtSameMonthAs(otherDate)); // false
print(specificDate.isAtSameDayAs(otherDate)); // false
```

You can also delay code execution:

```dart
Expand Down

0 comments on commit c444037

Please sign in to comment.