ethiopianToGregorian static method

Map<String, int> ethiopianToGregorian({
  1. required int year,
  2. required int month,
  3. required int day,
})

Convert Ethiopian date to Gregorian date Input: year, month, day in Ethiopian calendar Returns: Map with 'year', 'month', 'day' keys for Gregorian date

Implementation

static Map<String, int> ethiopianToGregorian({
  required int year,
  required int month,
  required int day,
}) {
  try {
    final ethiopianDate = EtDatetime(year: year, month: month, day: day);
    // Use UTC to avoid timezone-related off-by-one errors
    final gregorianDate = DateTime.fromMillisecondsSinceEpoch(
      ethiopianDate.moment,
      isUtc: true,
    );

    return {
      'year': gregorianDate.year,
      'month': gregorianDate.month,
      'day': gregorianDate.day,
    };
  } catch (e) {
    throw Exception('Invalid Ethiopian date: $e');
  }
}