import 'package:intl/intl.dart';

extension AppStringExtension on String {
  String currencyFormat() {
    final numberFormat = NumberFormat.currency(
      locale: 'id_ID',
      decimalDigits: 0,
      symbol: 'Rp ',
    );
    return numberFormat.format(double.parse(this));
  }

  String dateFormat() {
    final dateFormatFromApi = DateFormat('yyyy-M-dd hh:mm:ss');
    // final dateFormat = DateFormat('dd MMM yyyy');
    final dateFormat = DateFormat('dd/M/yy');
    return dateFormat.format(dateFormatFromApi.parse(this));
  }

  String dateFormatdmy() {
    final dateFormatFromApi = DateFormat('yyyy-M-dd hh:mm:ss');
    // final dateFormat = DateFormat('dd MMM yyyy');
    final dateFormat = DateFormat('dd-MM-yyyy hh:mm:ss');
    return dateFormat.format(dateFormatFromApi.parse(this));
  }

  String dateFormatdmyHistorical() {
    final dateFormatFromApi = DateFormat('yyyy-MM-dd');
    // final dateFormat = DateFormat('dd MMM yyyy');
    final dateFormat = DateFormat('dd-MM-yyyy');
    return dateFormat.format(dateFormatFromApi.parse(this));
  }
}

String formatBulanIndo(String tanggal) {
  DateTime dateTime = DateFormat("yyyy-MM-dd").parse(tanggal);

  var m = DateFormat('MM').format(dateTime);
  var month = "";
  switch (m) {
    case '01':
      {
        month = "Januari";
      }
      break;
    case '02':
      {
        month = "Februari";
      }
      break;
    case '03':
      {
        month = "Maret";
      }
      break;
    case '04':
      {
        month = "April";
      }
      break;
    case '05':
      {
        month = "Mei";
      }
      break;
    case '06':
      {
        month = "Juni";
      }
      break;
    case '07':
      {
        month = "Juli";
      }
      break;
    case '08':
      {
        month = "Agustus";
      }
      break;
    case '09':
      {
        month = "September";
      }
      break;
    case '10':
      {
        month = "Oktober";
      }
      break;
    case '11':
      {
        month = "November";
      }
      break;
    case '12':
      {
        month = "Desember";
      }
      break;
  }
  return month;
}
