part of 'extension.dart';

const List<String> _dayNames = [
  'Senin',
  'Selasa',
  'Rabu',
  'Kamis',
  'Jumat',
  'Sabtu',
  'Minggu',
];

const List<String> _monthNames = [
  'Januari',
  'Februari',
  'Maret',
  'April',
  'Mei',
  'Juni',
  'Juli',
  'Agustus',
  'September',
  'Oktober',
  'November',
  'Desember',
];

extension DateTimeExt on DateTime {
  String toFormattedDayDate() {
    String dayName = _dayNames[weekday - 1];
    String day = this.day.toString();
    String month = _monthNames[this.month - 1];
    String year = this.year.toString();

    return '$dayName, $day $month $year';
  }

  String toFormattedDate() {
    String day = this.day.toString();
    String month = _monthNames[this.month - 1];
    String year = this.year.toString();

    return '$day $month $year';
  }

  String toFormattedDateTime() {
    String day = this.day.toString();
    String month = _monthNames[this.month - 1];
    String year = this.year.toString();
    String hour = this.hour.toString().padLeft(
      2,
      '0',
    ); // Menambahkan nol di depan jika jam hanya satu digit
    String minute = this.minute.toString().padLeft(
      2,
      '0',
    ); // Menambahkan nol di depan jika menit hanya satu digit
    String second = this.second.toString().padLeft(
      2,
      '0',
    ); // Menambahkan nol di depan jika detik hanya satu digit

    return '$day $month $year, $hour:$minute:$second';
  }

  String toServerDate() {
    return DateFormat('dd-MM-yyyy').format(this);
  }

  String toSimpleMonthDate() {
    return DateFormat('dd MMM yyyy').format(this);
  }
}
