Esempio n. 1
0
def lunar_today():
    '''
        Return today's lunar date
    '''
    day1=[u"初", u"十", u"廿", u"三"]
    day2=[u"十", u"一", u"二", u"三", u"四", u"五", u"六", u"七", u"八", u"九"]
    month=day2[:]
    month[1] = u"正"
    month.extend([u"十", u"冬", u"腊"])
    return u"%s月%s%s" % (month[LunarDate.today().month],
                       day1[(LunarDate.today().day)/10],
                       day2[LunarDate.today().day%10])
 def get(self):
     today_ld = LunarDate.today()
     q1 = MessagingJob.query(MessagingJob.lunar_month == today_ld.month, MessagingJob.lunar_day == today_ld.day)
     for job in q1.iter():
         mail.send_mail(
             sender=SENDER,
             to=job.owner.email(),
             subject="Lunar Calendar Reminder - " + job.note,
             body=EMAIL_BODY % (job.owner.nickname(), job.note, job.getNextRun()),
         )
Esempio n. 3
0
    def check_birth(self):
        """
        查询明天生日的人,百度查询,今天是农历几月几日
        """
        new_today = datetime.datetime.now()
        old_today = LunarDate.today()
        tomorrow = datetime.timedelta(days=1)

        peoples = []
        for _i in range(7):
            peoples.append(
                People.objects.filter((Q(birth_lunar__month=old_today.month)
                                       & Q(birth_lunar__day=old_today.day))
                                      | (Q(birth_new__month=new_today.month)
                                         & Q(birth_new__day=new_today.day))))
            new_today += tomorrow
            old_today += tomorrow
        email = self.generate_birth_email(peoples)
        send_email(email, '好友生日提醒', settings.CRON_MAIL)
Esempio n. 4
0
    def check_birth(self):
        """
        查询明天生日的人,百度查询,今天是农历几月几日
        """
        new_today = datetime.datetime.now()
        old_today = LunarDate.today()
        tomorrow = datetime.timedelta(days=1)

        peoples = []
        for _i in range(7):
            peoples.append(People.objects.filter(
                (
                    Q(birth_lunar__month=old_today.month) &
                    Q(birth_lunar__day=old_today.day)
                ) |
                (
                    Q(birth_new__month=new_today.month) &
                    Q(birth_new__day=new_today.day)
                )
            ))
            new_today += tomorrow
            old_today += tomorrow
        email = self.generate_birth_email(peoples)
        send_email(email, '好友生日提醒', settings.CRON_MAIL)