示例#1
0
def getJHolidayList(date, isDiaspora=False, isNightFall=False):
  fixed = calendrical.fixedFromGregorian(date.year, date.month, date.day)
  if isNightFall:
    fixed+=1
  hebDate = calendrical.hebrewFromFixed(fixed)
  hebYear, hebMonth, hebDay = hebDate

  holidays = buildHolidays(hebYear,isDiaspora)
  key = (hebMonth,hebDay)
  if key in holidays:
    return holidays[key]
  else:
    return []
示例#2
0
def getCalendarFlags(date, isDiaspora, isNightFall):
    """Get a regexp match for the date"""
    holidays = getJHolidayList(date, isDiaspora, isNightFall)

    flags = []
    if Pesach in holidays:
      flags += ['pesah']
    elif Shavuot in holidays:
      flags += ['shavuot']
    elif ShminiAtzeret in holidays:
      flags += ['shemini']
    elif Purim in holidays:
      flags += ['purim']
    elif Hannuka in holidays:
      flags += ['hanukka']

    # Check for rosh chodesh
    fixed = calendrical.fixedFromGregorian(date.year, date.month, date.day)
    hebrew_date = calendrical.hebrewFromFixed(fixed)
    hebYear, hebMonth, hebDay = hebrew_date[0], hebrew_date[1], hebrew_date[2]
    if hebDay == 1 or hebDay == 30:
      flags += ['rosh-hodesh']

    # Other flags. TBD - Add more

    # Omer
    if ((hebMonth == 1 and hebDay>15) 
        or hebMonth == 2
        or (hebMonth == 3 and hebDay < 6)):
        flags += ['Omer']

    # LeDavid
    if (hebMonth == 6
        or (hebMonth == 7 and hebDay < 22)):
        flags += ['LeDavid']

    # tshuva
    if (hebMonth == 7 and hebDay < 10):
        flags += ['tshuva']

    return "|".join(flags)