Last active
December 22, 2020 01:44
-
-
Save valterh4ck3r/a447a8c2664fec9560dc66c45e758f69 to your computer and use it in GitHub Desktop.
Dart isToday DateTime Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension DateTimeExtension on DateTime { | |
bool isSameDay(DateTime otherDate){ | |
DateTime today = DateTime.now(); | |
return otherDate.day == today.day && otherDate.month == today.month && otherDate.year == today.year; | |
} | |
bool isToday(){ | |
DateTime today = DateTime.now(); | |
return this.day == today.day && this.month == today.month && this.year == today.year; | |
} | |
bool isAfterToday(){ | |
DateTime today = DateTime(DateTime.now().year , DateTime.now().month , DateTime.now().day , 23, 59); | |
return this.isAfter(today); | |
} | |
bool isBeforeToday(){ | |
DateTime today = DateTime(DateTime.now().year , DateTime.now().month , DateTime.now().day , 00, 00); | |
return this.isBefore(today); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment