def getMesekerem1(self, boolean=False): result = int( (self.__year + constants.Constants().ameteFida + self.rabeet) % 7) if boolean: return constants.Constants().weekdays[result] else: return str(result)
def _monthDays(self, geezDay = False, weekDayName = False): result = [0] * 4 yr = Et.EtDateTime(self.year,self.month) monthBeginning = yr.getWeekday() if yr.getMonth() == 13: if yr.isLeap(): daysInMonth = 6 else: daysInMonth = 5 else: daysInMonth = 30 for i in range(daysInMonth): if (geezDay): result[0] = self.year result[1] = self.month result[2] = constants.Constants().dayNumbers[i] if weekDayName: result[3] = constants.Constants().weekdays[monthBeginning] else: result[3] = monthBeginning else: result[0] = self.year result[1] = self.month result[2] = i + 1 if weekDayName: result[3] = constants.Constants().weekdays[monthBeginning] else: result[3] = monthBeginning monthBeginning = (monthBeginning + 1) % 7; return result;
def monthDays(self, geezDay = False, weekDayName = False): result = [0]* 4 monthBeginning = self.monthRange()[0] daysInMonth = self.monthRange()[1] for i in range(daysInMonth): if (geezDay): result[0] = self.year result[1] = self.month result[2] = constants.Constants().dayNumbers[i] if weekDayName: result[3] = constants.Constants().weekdays[monthBeginning] else: result[3] = monthBeginning else: result[0] = self.year result[1] = self.month result[2] = i + 1 if weekDayName: result[3] = constants.Constants().weekdays[monthBeginning] else: result[3] = monthBeginning monthBeginning = (monthBeginning + 1) % 7; return result;
def __init__(self, year=None, month=1, day=1, hour=0, minute=0, second=0, millisecond=0): if year == None: localtime = str( datetime.now(timezone.utc).astimezone( pytz.timezone("Africa/Addis_Ababa"))) lst_now = self._parse(str(localtime)) year, month, day = lst_now[0], lst_now[1], lst_now[2] Ethiopia_day = util.Util().gregorianToEthiopic(year, month, day) self.__year = Ethiopia_day[0] else: self.__year = year self.__month = month self.__day = day self.__hour = hour self.__minute = minute self.__second = second self.__millisecond = millisecond self.__monthGeez = constants.Constants().months[self.__month - 1] self.__dayGeez = constants.Constants().dayNumbers[self.__day - 1] self.fixed = self.fixedFromEthiopic(year, month, day) self.moment = self._dateToEpoch(year, month, day, hour, minute, second, millisecond)
def convert_11_100_ToGeez(self, num): if num == 100: return Constants.Constants().geezNumbers[num] result = self.divide(num, 10) if result[1] != 0: return Constants.Constants().geezNumbers[ result[0] * 10] + Constants.Constants().geezNumbers[result[1]] return Constants.Constants().geezNumbers[result[0] * 10]
def convertToGeez(self, num): result = "empty" if num < 1: raise exceptions.EthiopicNumberException( "Zero (0) and Negative numbers doesn't exsit in Ethiopic numerals " ) elif num >= 1 and num < 11: result = self.convert_1_10_ToGeez(num) elif num > 10 and num < 101: result = self.convert_11_100_ToGeez(num) elif num > 100 and num < 1001: result = self.convert_101_1000_ToGeez(num) elif num > 1001 and num < 10001: result = self.divide(num, 1000) if num == 10000: result = Constants.Constants().geezNumbers[10000] elif result[1] != 0: if result[1] < 11: result = Constants.Constants( ).geezNumbers[result[0] * 10] + Constants.Constants( ).geezNumbers[100] + self.convert_1_10_ToGeez(result[1]) elif result[1] < 101: result = Constants.Constants( ).geezNumbers[result[0] * 10] + Constants.Constants( ).geezNumbers[100] + self.convert_11_100_ToGeez(result[1]) else: result = Constants.Constants().geezNumbers[ result[0] * 10] + Constants.Constants( ).geezNumbers[100] + self.convert_101_1000_ToGeez( result[1]) else: result = Constants.Constants().geezNumbers[ result[0] * 10] + Constants.Constants().geezNumbers[100] return result
def convert_1_10_ToGeez(self, num): if num < 1: raise exceptions.EthiopicNumberException( "Zero (0) and Negative numbers doesn't exsit in Ethiopic numerals " ) else: return Constants.Constants().geezNumbers[num]
def _dateToEpoch(self, year, month, date, hour, minute, second, millisecond): constant = constants.Constants() return ( (self.fixedFromEthiopic(year, month, date) - constant.unixEpoch) * constant.dayMilliSec) + (hour * constant.hourMilliSec) + ( minute * constant.minMilliSec) + ( second * constant.secMilliSec) + millisecond
def getAllAtswamat(self, beal, numOfDays): mebjaHamer = self.getNewewe() all = {} h2 = {} h2["month"] = constants.Constants().months[ util.Util().indexOf(mebjaHamer["month"], constants.Constants().months) + (numOfDays // 30)] values = [beal, h2] if (int(mebjaHamer["date"]) + numOfDays) % 30 == 0: h2["date"] = "30" else: h2["date"] = str((int(mebjaHamer["date"]) + numOfDays) % 30) all = util.Util().getAllAtswamatwDate(values) return all
def yearDays (self, geezDay = False, weekDayName = False): result = [0] * 4 for i in range(len(constants.Constants().months)): result[0] = self.year result[1] = i + 1 result[2] = geezDay result[3] = weekDayName return result
def getSingleBealOrTsom(self, name): status = self.isMovableHoliday(name) if status: mebajaHamer = self.getNewewe() tewsak = int(constants.Constants().yebealTewsak[name]) values = [ constants.Constants().months[( util.Util().indexOf(mebajaHamer["month"], constants.Constants().months) + (int(mebajaHamer["date"]) + tewsak) // 30)], str((int(mebajaHamer["date"]) + tewsak) % 30) ] else: raise exception.BealNameException( "Holiday is not a movable one. Please provide holidays between ነነዌ and ጾመ ድህነት" ) return util.Util().getSingleBealOrTsomDate(values)
def withValue(self, fixed, moment): constant = constants.Constants() year = (4 * (fixed - constant.ethiopicEpoch) + 1463) // 1461 month = int(((fixed - self.fixedFromEthiopic(year, 1, 1)) // 30) + 1) day = int(fixed + 1 - self.fixedFromEthiopic(year, month, 1)) hour = int((moment / constant.hourMilliSec) % 24) minute = int((moment / constant.minMilliSec) % 60) second = int((moment / constant.secMilliSec) % 60) millisecond = int((float(moment) % 1000)) return EtDateTime(year, month, day, hour, minute, second, millisecond)
def convert_101_1000_ToGeez(self, num): result = self.divide(num, 100) if num == 1000: return Constants.Constants().geezNumbers[1000] if result[1] != 0: if result[1] < 11: return Constants.Constants().geezNumbers[ result[0]] + Constants.Constants( ).geezNumbers[100] + self.convert_1_10_ToGeez(result[1]) else: return Constants.Constants().geezNumbers[ result[0]] + Constants.Constants( ).geezNumbers[100] + self.convert_11_100_ToGeez(result[1]) return Constants.Constants().geezNumbers[ result[0]] + Constants.Constants().geezNumbers[100]
def getNewewe(self): meskerem1 = self.getMesekerem1(True) month = self.getYebealMitkehWer() day_tewsak = 0 for i in util.Util().getyeeletTewsak().keys(): if i == constants.Constants().weekdays[(util.Util().indexOf( meskerem1, constants.Constants().weekdays) + self.metkih - 1) % 7]: day_tewsak = util.Util().getyeeletTewsak()[i] monthName = "" if day_tewsak + self.metkih > 30: monthName = "የካቲት" else: monthName = "ጥር" if month == 2: monthName = "የካቲት" tikimt1 = constants.Constants().weekdays[ (util.Util().indexOf(meskerem1, constants.Constants().weekdays) + 2) % 7] metkihElet = constants.Constants().weekdays[(util.Util().indexOf( tikimt1, constants.Constants().weekdays) + self.metkih - 1) % 7] for i in util.Util().getyeeletTewsak().keys(): if i == constants.Constants().weekdays[(util.Util().indexOf( metkihElet, constants.Constants().weekdays) + self.metkih - 1) % 7]: day_tewsak = util.Util().getyeeletTewsak()[i] date = self.metkih + day_tewsak value = [monthName] if date % 30 == 0: value.append(str(30)) else: value.append(str(date % 30)) return util.Util().getNeweweDate(value)
from Util import Constants print(Constants.path_final_documents) Constants.a(Constants)
def getEvange(self, boolean=False): result = self.ameteAlem % 4 if boolean: return constants.Constants().evangelists[result] else: return str(result)
def getGeezDay(self): return constants.Constants().dayNumbers[self.day - 1]
def fixedFromEthiopic(self, year, month, day): return (constants.Constants().ethiopicEpoch - 1) + (365 * (year - 1)) + (year / 4) + (30 * (month - 1)) + day
def fixedFromUnix(self, ms): return (constants.Constants().unixEpoch + int(ms / 86400000))
def yearFirstDay(self): rabeet = (self.year + constants.Constants().ameteFida) // 4 return (constants.Constants().ameteFida + rabeet) % 7
def isMovableHoliday(self, name): if name in constants.Constants().yebealTewsak: return True return False