convertToGregorianDate static method
Implementation
static DateTime convertToGregorianDate(DateTime datetime) {
int addDays = 1;
int tempMonth = 1;
bool isLeapYear = (datetime.year - 1) % 4 == 3;
if (EthiopianMonth.meskerem <= datetime.month &&
datetime.month <= EthiopianMonth.tahsas) {
year = datetime.year + 7;
} else {
year = datetime.year + 8;
}
//isLeapYear = (year +1) % 4 == 0;
if (EthiopianMonth.meskerem == datetime.month) {
tempMonth = 9;
if (isLeapYear) {
addDays = 11;
} else {
addDays = 10;
}
} else if (EthiopianMonth.tikimt == datetime.month) {
tempMonth = 10;
if (isLeapYear) {
addDays = 11;
} else {
addDays = 10;
}
} else if (EthiopianMonth.hidar == datetime.month) {
tempMonth = 11;
if (isLeapYear) {
addDays = 10;
} else {
addDays = 9;
}
} else if (EthiopianMonth.tahsas == datetime.month) {
tempMonth = 12;
if (isLeapYear) {
addDays = 10;
} else {
addDays = 9;
}
} else if (EthiopianMonth.tir == datetime.month) {
tempMonth = 1;
if (isLeapYear) {
addDays = 9;
} else {
addDays = 8;
}
} else if (EthiopianMonth.yakatit == datetime.month) {
tempMonth = 2;
if (isLeapYear) {
addDays = 8;
} else {
addDays = 7;
}
} else if (EthiopianMonth.maggabit == datetime.month) {
tempMonth = 3;
addDays = 9;
} else if (EthiopianMonth.miyazya == datetime.month) {
tempMonth = 4;
addDays = 8;
} else if (EthiopianMonth.ginbot == datetime.month) {
tempMonth = 5;
addDays = 8;
} else if (EthiopianMonth.sene == datetime.month) {
tempMonth = 6;
addDays = 7;
} else if (EthiopianMonth.hamle == datetime.month) {
tempMonth = 7;
addDays = 7;
} else if (EthiopianMonth.nehasa == datetime.month) {
tempMonth = 8;
addDays = 6;
} else if (EthiopianMonth.pagume == datetime.month) {
tempMonth = 9;
addDays = 5;
}
calculateDayAndMonth(tempMonth, datetime.day, addDays, isLeapYear);
DateTime gregorianDateTime = DateTime(year, month, date);
return gregorianDateTime;
}