import 'package:intl/intl.dart';

extension DateTimeExtension on DateTime {
  String toHourMinuteString() {
    return '${hour.toString().padLeft(2, '0')}:'
        '${minute.toString().padLeft(2, '0')}';
  }

  String getDayDateId() => '$year$month$day';

  String getWeekdayId() => switch (weekday) {
        DateTime.monday => 'monday',
        DateTime.tuesday => 'tuesday',
        DateTime.wednesday => 'wednesday',
        DateTime.thursday => 'thursday',
        DateTime.friday => 'friday',
        DateTime.saturday => 'saturday',
        _ => 'sunday',
      };

  String toDayMonthYearString() => DateFormat('dd.MM.yyyy').format(this);

  DateTime tillDay() {
    return DateTime(year, month, day);
  }

  DateTime toTenthsMinute() {
    if (minute % 10 == 0) return this;

    return DateTime(year, month, day, hour, minute - minute % 10);
  }
}
