Пример #1
0
    def hebrew_to_gregorian(self,
                            year,
                            hebrew_month,
                            hebrew_day,
                            year_is_gregorian=1):
        if year_is_gregorian:
            # gregorian year is either 3760 or 3761 years less than hebrew year
            # we'll first try 3760 if conversion to gregorian isn't the same
            # year that was passed to this method, then it must be 3761.
            for y in (year + HEBREW_YEAR_OFFSET,
                      year + HEBREW_YEAR_OFFSET + 1):
                jd = calendar_util.hebrew_to_jd(y, hebrew_month, hebrew_day)
                gd = calendar_util.jd_to_gregorian(jd)
                if gd[YEAR] == year:
                    break
                else:
                    gd = None
        else:
            jd = calendar_util.hebrew_to_jd(year, hebrew_month, hebrew_day)
            gd = calendar_util.jd_to_gregorian(jd)

        if not gd:  # should never occur, but just incase...
            raise RangeError, "Could not determine gregorian year"

        return gd  # (tuple:  y. m, d))
Пример #2
0
    def hebrew_to_gregorian(self, year, hebrew_month, hebrew_day, year_is_gregorian=1):
        if year_is_gregorian:
            # gregorian year is either 3760 or 3761 years less than hebrew year
            # we'll first try 3760 if conversion to gregorian isn't the same
            # year that was passed to this method, then it must be 3761.
            for y in (year + HEBREW_YEAR_OFFSET, year + HEBREW_YEAR_OFFSET + 1):
                jd = calendar_util.hebrew_to_jd(y, hebrew_month, hebrew_day)
                gd = calendar_util.jd_to_gregorian(jd)
                if gd[YEAR] == year:
                    break
                else:
                    gd = None
        else:
            jd = calendar_util.hebrew_to_jd(year, hebrew_month, hebrew_day)        
            gd = calendar_util.jd_to_gregorian(jd)

        if not gd: # should never occur, but just incase...
            raise RangeError, "Could not determine gregorian year"
        
        return gd # (tuple:  y. m, d))
Пример #3
0
    def hebrew_to_gregorian(self, year, hebrew_month, hebrew_day,
                             is_gregorian_year=True):
        if not year:
            year = self.year

        if is_gregorian_year:
            for y in (year + HEBREW_YEAR_OFFSET, year + HEBREW_YEAR_OFFSET + 1):
                jd = calendar_util.hebrew_to_jd(y, hebrew_month, hebrew_day)
                gd = calendar_util.jd_to_gregorian(jd)
                if gd[YEAR] == year:
                    break
                else:
                    gd = None
        else:
            jd = calendar_util.hebrew_to_jd(year, hebrew_month, hebrew_day)
            gd = calendar_util.jd_to_gregorian(jd)

        if not gd:
            raise RangeError, "Couldn't determine the Gregorian year"
        else:
            return gd