hourStringOrganization static method

String hourStringOrganization(
  1. String hourFromLine
)

Fixing a string hour of whatsapp to a parsable dart date

Implementation

static String hourStringOrganization(String hourFromLine) {
  String hour = hourFromLine.split(':')[0];
  String minute = hourFromLine.split(':')[1].split(' ')[0];
  if (hourFromLine.split(' ').length == 1) return '${fixMonthOrDayTo01(hour)}:$minute:00';
  if (hourFromLine.split(' ')[1] == 'PM') {
    hour = '${int.parse(hour) + 12}';
  } else {
    hour = fixMonthOrDayTo01(hour);
  }
  return "$hour:$minute:00";
}