From 64f13bf8a7e584c79588557806a0ad128d37fafd Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Wed, 27 May 2020 16:16:25 +0300 Subject: [PATCH] checkDate (today tommorow ,next week) --- lib/util/helpers.dart | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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