diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 45ad043d..b8e86e16 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -165,6 +165,37 @@ class Helpers { ), ); } + /* + *@author: Amjad Amireh + *@Date:5/5/2020 + *@param: checkDate + *@return: DateTime + *@desc: convert String to DateTime + */ +static String checkDate(String dateString) { + DateTime checkedTime = DateTime.parse(dateString); + DateTime currentTime = DateTime.now(); + + if ((currentTime.year == checkedTime.year) && + (currentTime.month == checkedTime.month) && + (currentTime.day == checkedTime.day)) { + return "Today"; + } else if ((currentTime.year == checkedTime.year) && + (currentTime.month == checkedTime.month)) { + if ((currentTime.day - checkedTime.day) == 1) { + return "YESTERDAY"; + } else if ((currentTime.day - checkedTime.day) == -1) { + return "Tomorrow"; + } + + if ((currentTime.day - checkedTime.day) <= -2) { + return "Next Week"; + } else { + return "Old Date"; + } + } + return "Old Date"; + } /* *@author: Mohammad Aljammal @@ -268,6 +299,9 @@ class Helpers { return myWorkingHours; } + + + /* *@author: Elham Rababah *@Date:12/5/2020