import 'package:intl/intl.dart';

class DateHelper {
  static String formatDateT(String dateString) {
    return dateString.split('T')[0];
  }

  static DateTime parseStringToDate(String dateString) {
    final formatter = DateFormat('yyyy-MM-dd');
    return formatter.parse(dateString);
  }

  static String formatAsShortDate(DateTime date) {
    final formatter = DateFormat.yMd();
    return formatter.format(date);
  }

  static String formatAsLongDate(DateTime date) {
    final formatter = DateFormat.yMMMMEEEEd();
    return formatter.format(date);
  }

  static String formatAsTime(DateTime date) {
    final formatter = DateFormat.jm();
    return formatter.format(date);
  }

  static String formatAsYearMonthDay(DateTime date) {
    final formatter = DateFormat('y-MM-d');
    return date != null ? formatter.format(date) : "N/A";
  }

  static String formatAsCustomPattern(DateTime date, String pattern) {
    final formatter = DateFormat(pattern);
    return formatter.format(date);
  }

  static String formatAsDayMonthYear(DateTime? date) {
    final formatter = DateFormat('d MMM, y');
    return date != null ? formatter.format(date) : "N/A";
  }

  static String formatAsMonthDayYear(DateTime date) {
    final formatter = DateFormat('MMMM d, y');
    return formatter.format(date);
  }

  static String formatAsMonthYear(DateTime date) {
    final formatter = DateFormat('MMMM y');
    return formatter.format(date);
  }
}
