formatFive function
Implementation
DateTime? formatFive(String date) {
DateTime? maybeTime;
try {
List<String> splittedTimes = date.split(" ");
int weekday =
weekdays.indexWhere((element) => element.startsWith(splittedTimes[0])) +
1;
maybeTime = DateFormat("dd/MM-yy").parse(splittedTimes[1]);
var now = DateTime.now();
int weekdayDifference = now.weekday - weekday;
var realDate = now.subtract(Duration(days: weekdayDifference));
maybeTime = maybeTime.copyWith(
year: realDate.year, month: realDate.month, day: realDate.day);
return maybeTime;
} catch (_) {
return maybeTime;
}
}