Skip to content

Instantly share code, notes, and snippets.

@valterh4ck3r
Last active December 22, 2020 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valterh4ck3r/a447a8c2664fec9560dc66c45e758f69 to your computer and use it in GitHub Desktop.
Save valterh4ck3r/a447a8c2664fec9560dc66c45e758f69 to your computer and use it in GitHub Desktop.
Dart isToday DateTime Extension
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