ago property

String ago

Implementation

String get ago {
      int min = DateTime.now().difference(this).inMinutes;
      int count = 0;
      String text = '';
      if(min < 60) {
        count = max(min, 0);
        text = 'm';
      }
      else if(min < 60 * 24) {
        count = min ~/60;
        text = 'h';
      }
      else if(min < 60 * 24 * 7) {
        count = min ~/(60 * 24);
        text = 'd';
      }
      else {
        count = min~/(60*24*7);
        text = 'w';
      }
      text = text.tr;
      return Get.locale?.languageCode == 'ar' ? '${'ago'.tr} $count $text':'$count $text ${'ago'.tr}';
    }