fromDateStr static method
Implementation
static String fromDateStr(String strTime) {
/// if time is greater than a week {first checks > writtn on memo}
final diffDays = DateTime.parse(strTime).difference(DateTime.now().toUtc()).inDays;
if (diffDays <= -7) {
final week = (diffDays ~/ -7).toInt();
/// calcs Week
return week.toString().replaceAll('-', '') + 'w';
} else if (diffDays <= -1 && diffDays > -7) {
/// return days > still same increment on memo
return diffDays.toString().replaceAll('-', '') + 'd';
} else {
final diffHours = DateTime.parse(strTime).difference(DateTime.now().toUtc()).inHours;
/// if not {third checks > 2° writtn on memo}
if (diffHours <= -1) {
return diffHours.toString().replaceAll('-', '') + 'h';
} else {
/// if not {last checks > last writtn on memo}
final diffMin = DateTime.parse(strTime).difference(DateTime.now().toUtc()).inMinutes;
if (diffMin <= -1) {
return diffMin.toString().replaceAll('-', '') + 'm';
} else {
return 'Now';
}
}
}
}