def __init__(self,date,date_unit): date_unit=date_unit.lower() if date_unit in ["jalali","gregorian"]: AbsDate.__init__(self,date,date_unit) else: date=time_lib.dbTimeFromEpoch(time.time()+self.__getDateInSeconds(date,date_unit)) AbsDate.__init__(self,date,"gregorian")
def __init__(self, date, date_unit, go_past=True): """ date(string): date value date_unit(string): unit of date can be "jalali" "gregorian" "years" "months" "days" "hours" "minutes" go_past(bool): if date_unit is not absolute (jalali , gregorian) should we subtract or add relative date to now if go_past is true, we subtract relative date from now """ date_unit = date_unit.lower() if date_unit in ["jalali", "gregorian"]: AbsDate.__init__(self, date, date_unit) else: if go_past: op = operator.sub else: op = operator.add date = time_lib.dbTimeFromEpoch( op(time.time(), self.__getDateInSeconds(date, date_unit))) AbsDate.__init__(self, date, "gregorian")
def AbsDateFromEpoch(epoch_time): return AbsDate(time_lib.dbTimeFromEpoch(epoch_time),"gregorian")
def AbsDateFromEpoch(epoch_time): return AbsDate(time_lib.dbTimeFromEpoch(epoch_time), "gregorian")