getTimeFromAngles static method

String getTimeFromAngles(
  1. double angleInRadians
)

Implementation

static String getTimeFromAngles(double angleInRadians) {
  String median = "AM";
  if (angleInRadians >= pi) {
    //PM part
    angleInRadians -= pi;
    median = "PM";
  }
  double ratio = angleInRadians / pi;
  double hoursInHundreds = ratio * 12;
  int hour = hoursInHundreds.floor();
  int minutes = ((hoursInHundreds - hour) * 60).ceil();
  if (minutes == 60) {
    hour += 1;
    minutes = 0;
  }
  if (hour == 0) {
    hour = 12;
  }
  return "${hour < 10 ? '0$hour' : hour}:${minutes < 10 ? '0$minutes' : minutes} $median";
}