import 'package:intl/intl.dart';

String capitalize(String s) {
  return s[0].toUpperCase() + s.substring(1);
}

String dateFormater(String date) {
  final DateTime dateTime = DateTime.parse(date);
  final DateFormat formatter = DateFormat('dd MMM yyyy');
  return formatter.format(dateTime);
}

String dateFormatterShort(String date) {
  final DateTime dateTime = DateTime.parse(date);
  final DateFormat formatter = DateFormat('yyyy-MM-dd');
  return formatter.format(dateTime);
}

String setTwoDigitAfterComma(double number) {
  return number.toStringAsFixed(2);
}

String getGreeting(String time) {
  DateTime parsedTime = DateTime.parse(time);
  int hour = parsedTime.hour;

  if (hour >= 5 && hour < 12) {
    return 'Selamat Pagi';
  } else if (hour >= 12 && hour < 15) {
    return 'Selamat Siang';
  } else if (hour >= 15 && hour < 18) {
    return 'Selamat Sore';
  } else {
    return 'Selamat Malam';
  }
}
