You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fluffychat/lib/pangea/utils/p_extension.dart

13 lines
386 B
Dart

extension IsAtLeastYearsOld on DateTime {
bool isAtLeastYearsOld(int years) {
final now = DateTime.now();
final boundaryDate = DateTime(now.year - years, now.month, now.day);
// Discard the time from [this].
final thisDate = DateTime(year, month, day);
// Did [thisDate] occur on or before [boundaryDate]?
return thisDate.compareTo(boundaryDate) <= 0;
}
}