countWeeks function

String countWeeks(
  1. int difference
)

Converts the time difference to a number of weeks. This function truncates to the lowest week. returns ("1 week" OR "X weeks" OR "1 month")

Implementation

String countWeeks(int difference) {
  int count = (difference / 604800000).truncate();
  if (count > 3) {
    return '1 month';
  }
  return count.toString() + (count > 1 ? ' weeks' : ' week');
}