def from_fixed(cls, fixed_date): """Return Hebrew (year month day) corresponding to fixed date 'fixed_date'. # The fraction can be approximated by 365.25.""" approx = quotient(fixed_date - cls.EPOCH, Fraction(35975351, 98496)) + 1 year = final_int(approx - 1, lambda y: cls.new_year(y) <= fixed_date) start = ( HebrewMonth.TISHRI if fixed_date < HebrewDate(year, HebrewMonth.NISAN, 1).to_fixed() else HebrewMonth.NISAN ) month = next_int(start, lambda m: fixed_date <= HebrewDate(year, m, cls.last_day_of_month(m, year)).to_fixed()) day = fixed_date - HebrewDate(year, month, 1).to_fixed() + 1 return HebrewDate(year, month, day)
def new_moon_before(cls, tee): """Return the moment UT of last new moon before moment tee.""" t0 = cls.nth_new_moon(0) phi = cls.lunar_phase(tee) n = iround(((tee - t0) / cls.MEAN_SYNODIC_MONTH) - (phi / 360)) return cls.nth_new_moon(final_int(n - 1, lambda k: cls.nth_new_moon(k) < tee))