aves/lib/utils/time_utils.dart
Thibault Deckers 84999053eb minor change
2021-08-25 12:27:16 +09:00

15 lines
546 B
Dart

extension ExtraDateTime on DateTime {
bool isAtSameYearAs(DateTime? other) => year == other?.year;
bool isAtSameMonthAs(DateTime? other) => isAtSameYearAs(other) && month == other?.month;
bool isAtSameDayAs(DateTime? other) => isAtSameMonthAs(other) && day == other?.day;
bool get isToday => isAtSameDayAs(DateTime.now());
bool get isYesterday => isAtSameDayAs(DateTime.now().subtract(const Duration(days: 1)));
bool get isThisMonth => isAtSameMonthAs(DateTime.now());
bool get isThisYear => isAtSameYearAs(DateTime.now());
}