Python calendar 模块,day_name() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用calendar.day_name()

项目:calendary    作者:DavidHickman    | 项目源码 | 文件源码
def weekday_calendar(self):
        """
        Append the weekday to each date for the calendar year.
        :return (list) of tuples ((str) weekday, datetime.date)
        """
        _weekday_calendar = set()

        for month in self.year_calendar:
            for week in month:
                for day in week:
                    if day.year == self.year:
                        _weekday_calendar.add(
                            (calendar.day_name[day.weekday()], day)
                        )

        return sorted(list(_weekday_calendar), key=lambda x: x[1])
项目:Jumper-Cogs    作者:Redjumpman    | 项目源码 | 文件源码
def _rashid_tibia(self):
        """Get Rashid's Location"""
        current_date = date.today()
        if calendar.day_name[current_date.weekday()] == "Sunday":
            await self.bot.say("On Sundays you can find him in Carlin depot, one floor above.")
        elif calendar.day_name[current_date.weekday()] == "Monday":
            await self.bot.say("On Mondays you can find him in Svargrond, in Dankwart's tavern, south of the temple.")
        elif calendar.day_name[current_date.weekday()] == "Tuesday":
            await self.bot.say("On Tuesdays you can find him in Liberty Bay, in Lyonel's tavern, west of the depot.")
        elif calendar.day_name[current_date.weekday()] == "Wednesday":
            await self.bot.say("On Wednesdays you can find him in Port Hope, in Clyde's tavern, north of the ship.")
        elif calendar.day_name[current_date.weekday()] == "Thursday":
            await self.bot.say("On Thursdays you can find him in Ankrahmun, in Arito's tavern, above the post office.")
        elif calendar.day_name[current_date.weekday()] == "Friday":
            await self.bot.say("On Fridays you can find him in Darashia, in Miraia's tavern, south of the guildhalls.")
        elif calendar.day_name[current_date.weekday()] == "Saturday":
            await self.bot.say("On Saturdays you can find him in Edron, in Mirabell's tavern, above the depot.")
        else:
            pass
项目:cpyparsing    作者:evhub    | 项目源码 | 文件源码
def convertToDay(toks):
    now = datetime.now()
    if "wkdayRef" in toks:
        todaynum = now.weekday()
        daynames = [n.lower() for n in calendar.day_name]
        nameddaynum = daynames.index(toks.wkdayRef.day.lower())
        if toks.wkdayRef.dir > 0:
            daydiff = (nameddaynum + 7 - todaynum) % 7
        else:
            daydiff = -((todaynum + 7 - nameddaynum) % 7)
        toks["absTime"] = datetime(now.year, now.month, now.day)+timedelta(daydiff)
    else:
        name = toks.name.lower()
        toks["absTime"] = {
            "now"       : now,
            "today"     : datetime(now.year, now.month, now.day),
            "yesterday" : datetime(now.year, now.month, now.day)+timedelta(-1),
            "tomorrow"  : datetime(now.year, now.month, now.day)+timedelta(+1),
            }[name]
项目:cron-descriptor    作者:Salamek    | 项目源码 | 文件源码
def number_to_day(self, day_number):
        """Returns localized day name by its CRON number

        Args:
            day_number: Number of a day
        Returns:
            Day corresponding to day_number
        Raises:
            IndexError: When day_number is not found
        """
        return [
            calendar.day_name[6],
            calendar.day_name[0],
            calendar.day_name[1],
            calendar.day_name[2],
            calendar.day_name[3],
            calendar.day_name[4],
            calendar.day_name[5]
        ][day_number]
项目:pyirobot    作者:cseelye    | 项目源码 | 文件源码
def GetSchedule(self):
        """
        Get the cleaning schedule for this robot

        Returns:
            A dictionary representing the schedule per day (dict)
        """
        res = self._PostToRobot("get", "week")
        schedule = {}
        for idx in range(7):
            cal_day_idx = idx - 1
            if cal_day_idx < 0:
                cal_day_idx = 6
            schedule[calendar.day_name[cal_day_idx]] = {
                "clean" : True if res["cycle"][idx] == "start" else False,
                "startTime" : datetime.time(res["h"][idx], res["m"][idx])
            }
        return schedule
项目:sailcron    作者:a-dekker    | 项目源码 | 文件源码
def number_to_day(self, day_number):
        """Returns localized day name by its CRON number

        Args:
            day_number: Number of a day
        Returns:
            Day corresponding to day_number
        Raises:
            IndexError: When day_number is not found
        """
        # ADE force locale first...
        import locale
        locale.setlocale(locale.LC_ALL, '')
        return [
            calendar.day_name[6],
            calendar.day_name[0],
            calendar.day_name[1],
            calendar.day_name[2],
            calendar.day_name[3],
            calendar.day_name[4],
            calendar.day_name[5]
        ][day_number]
项目:Weather-App    作者:Tomasz-Kluczkowski    | 项目源码 | 文件源码
def finish_get_date(self, unix_time, dst_offset):
        """Converts date from unix time to string.

        Args:
            dst_offset: (bool) Set to True to offset time received from
                open weather API by daylight savings time.
            unix_time (int): Time given in seconds from beginning of the
                epoch as on unix machines.

        Returns:
            name_of_day (str): Name of the day on date.
            date_str (str): Date in string representation.
        """
        if dst_offset:
            dst_offset = self.v_link["timezone"]["dstOffset"] * 3600
        else:
            dst_offset = 0

        date = datetime.datetime.utcfromtimestamp(unix_time + dst_offset)
        date_str = date.strftime("%d/%m/%Y")
        name_of_day = calendar.day_name[date.weekday()]
        return name_of_day, date_str
项目:chef_community_cookbooks    作者:DennyZhang    | 项目源码 | 文件源码
def cb_backup_bucket(bucket, backup_method = ""):
    if backup_method == "":
        today = date.today()
        day = calendar.day_name[today.weekday()]
        # Run DB backup with complete/diff/accu in different days
        backup_method = weekday_method.get(day)
    backup_command = cb_backup_command(bucket, backup_method)
    log.info("Backup Couchbase bucket: %s, method: %s" % (bucket, backup_method))
    log.info("Run command: %s" % (backup_command))
    # TODO: get command output
    returncode = subprocess.call(backup_command, shell=True)
    if returncode != 0:
        log.error("Backup fails for %s" % (bucket))
        sys.exit(returncode)

################################################################################
项目:GoogleCalendar-Skill    作者:jcasoft    | 项目源码 | 文件源码
def getDateWeekday(weekday,eventHour):
    day_evaluate = weekday
    today = datetime.datetime.strptime(time.strftime("%x"),"%m/%d/%y")
    if ('am' in eventHour) or ('pm' in eventHour) or ('AM' in eventHour) or ('PM' in eventHour):
    start_hour = datetime.datetime.strptime(eventHour, "%I:%M %p").hour
        start_minute = datetime.datetime.strptime(eventHour, "%I:%M %p").minute
    else:
    start_hour = datetime.datetime.strptime(eventHour, "%I:%M").hour
        start_minute = datetime.datetime.strptime(eventHour, "%I:%M").minute

    for i in range(1,8):
    date = today + datetime.timedelta(days=i)
    day_name = date.strftime("%A")
    if (day_evaluate.upper() == day_name.upper()):
        date = date.replace(hour=start_hour, minute=start_minute)
        return date.isoformat() + gmt
项目:pyladies-march2017    作者:dmahugh    | 项目源码 | 文件源码
def cdow(date_or_year, month_int=1, day_int=1): #----------------------------<<<
    """Convert a date or year/month/day to a day-of-week string.

    date_or_year = a date/datetime, or year <int>

    If a year value is passed, then month_int
                   and day_int are required.
    month_int = month as <int>
    day_int = day as <int>

    Returns a weekday name (e.g., "Tuesday").
    """
    if isinstance(date_or_year, datetime.datetime):
        return calendar.day_name[date_or_year.weekday()]
    else:
        thedate = datetime.date(date_or_year, month_int, day_int)
        return calendar.day_name[thedate.weekday()]
项目:GoogleCalendarSkill    作者:jcasoft    | 项目源码 | 文件源码
def getDateWeekday(weekday,eventHour):
    day_evaluate = weekday
    today = datetime.datetime.strptime(time.strftime("%x"),"%m/%d/%y")
    if ('am' in eventHour) or ('pm' in eventHour) or ('AM' in eventHour) or ('PM' in eventHour):
    start_hour = datetime.datetime.strptime(eventHour, "%I:%M %p").hour
        start_minute = datetime.datetime.strptime(eventHour, "%I:%M %p").minute
    else:
    start_hour = datetime.datetime.strptime(eventHour, "%I:%M").hour
        start_minute = datetime.datetime.strptime(eventHour, "%I:%M").minute

    for i in range(1,8):
    date = today + datetime.timedelta(days=i)
    day_name = date.strftime("%A")
    if (day_evaluate.upper() == day_name.upper()):
        date = date.replace(hour=start_hour, minute=start_minute)
        return date.isoformat() + gmt
项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self, month, year, indent_level, indent_style):
        'x.__init__(...) initializes x'
        calendar.setfirstweekday(calendar.SUNDAY)
        matrix = calendar.monthcalendar(year, month)
        self.__table = HTML_Table(len(matrix) + 1, 7, indent_level, indent_style)
        for column, text in enumerate(calendar.day_name[-1:] + calendar.day_name[:-1]):
            self.__table.mutate(0, column, '<b>%s</b>' % text)
        for row, week in enumerate(matrix):
            for column, day in enumerate(week):
                if day:
                    self.__table.mutate(row + 1, column, '<b>%02d</b>\n<hr>\n' % day)
        self.__weekday, self.__alldays = calendar.monthrange(year, month)
        self.__weekday = ((self.__weekday + 1) % 7) + 6
项目:Harmonbot    作者:Harmon758    | 项目源码 | 文件源码
def day(self):
        '''Random day of week'''
        await self.bot.embed_reply(random.choice(calendar.day_name))
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:MIT-Hodor    作者:kalbhor    | 项目源码 | 文件源码
def timetable(values, data):
    today = calendar.day_name[date.today().weekday()].lower()
    tomorrow = calendar.day_name[(date.today().weekday() + 1) % 7].lower()

    #timetable = values['timetable']
    try:
        time = values['time'][0]['value']
    except KeyError:
        time = 'today'

    if time == 'today':
        time = today
    elif time == 'tomorrow':
        time = tomorrow

    if time == 'sunday':
        return "Sunday is not a working day."

    response = "The timetable for {} is : \n\n ".format(time.upper())

    for subj in data[time]:
        t, sub = subj
        response += "({}) - {} \n\n".format(t,sub)

    if len(data[time]) == 0:
        return "There are no classes or {} is a holiday".format(time.upper())

    return response
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:SSTV-PLEX-PLUGIN    作者:vorghahn    | 项目源码 | 文件源码
def formatShowText(channel, show, currentTime, formatString):
    language = ""
    when = ""

    if " - " in channel.name:
        chanName = channel.name.split(" - ")[1]
    else:
        chanName = channel.name

    if show is None:
        retVal = formatString.replace("{ch}", channel.channel_id).replace("{chname}", chanName)
    else:
        if "language" in show and show['language'].upper() != "US":
            language = show['language'].upper()

        if "720p" in chanName.lower():
            chanName = chanName.replace(" 720P", "HD")
        showTime = SmoothUtils.GetDateTimeNative(show['time'])
        if showTime > currentTime:
            if showTime.date() == currentTime.date():
                when = "LATER"
            else:
                when = calendar.day_name[showTime.weekday()][:3].upper()

        if "category" in show and show["name"].startswith(show["category"] + ":") and show["category"] != "News":
            show["name"] = show["name"].replace(show["category"] + ":", "").strip()

        retVal = formatString.replace("{ch}", channel.channel_id).replace("{chname}", chanName).replace("{title}", show['name']).replace("{qual}", show["quality"].replace("hqlq", "").replace("unk", "")).replace("{time}", SmoothUtils.GetShowTimeText(show)).replace("{lang}", language).replace("{when}", when).replace("{cat}", show['category'])

    return retVal.replace("()", "").replace("  ", " ").strip()
项目:aws-ops-automator    作者:awslabs    | 项目源码 | 文件源码
def test_name(self):
        for i, day_name in enumerate(calendar.day_abbr):
            self.assertEqual(WeekdaySetBuilder().build(day_name), {i})

        for i, day_name in enumerate(calendar.day_name):
            self.assertEqual(WeekdaySetBuilder().build(day_name), {i})
项目:pyirobot    作者:cseelye    | 项目源码 | 文件源码
def GetTime(self):
        """
        Get the time this robot is set to

        Returns:
            A dictionary with the time of day and day of week (dict)
        """
        result = self._PostToRobot("get", "time")
        day_idx = [idx for idx, day in enumerate(calendar.day_abbr) if day.lower() == result["d"]][0]
        return {
            "time" : datetime.time(result["h"], result["m"]),
            "weekday" : calendar.day_name[day_idx]
        }
项目:pyirobot    作者:cseelye    | 项目源码 | 文件源码
def SetSchedule(self, newSchedule):
        """
        Set the cleaning schedule for this robot.
        The easiest way to use this function is to call GetSchedule, modify
        the result, and use that as the input to this function

        Args:
            schedule:   the schedule to set (dict)
        """
        # Sort calendar day names into the order the robot expects
        days = {}
        for cal_idx, dayname in enumerate(calendar.day_name):
            idx = cal_idx + 1 if cal_idx < 6 else 0
            days[idx] = dayname

        sched = collections.OrderedDict([
            ("cycle", []),
            ("h", []),
            ("m", [])
        ])
        for idx in sorted(days):
            dayname = days[idx]
            if newSchedule[dayname]["clean"]:
                sched["cycle"].append("start")
            else:
                sched["cycle"].append("none")
            sched["h"].append(newSchedule[dayname]["startTime"].hour)
            sched["m"].append(newSchedule[dayname]["startTime"].minute)

        self._PostToRobot("set", ["week", sched])
项目:checkio    作者:fbreversg    | 项目源码 | 文件源码
def most_frequent_days(year):
    """
        List of most frequent days of the week in the given year
    """

    firstweek = set(range(datetime(year, 1, 1).weekday(), 7))   # weekday 0..6
    lastweek = set(range(datetime(year, 12, 31).isoweekday()))  # isoweekday 1..7
    return [day_name[day] for day in sorted((firstweek & lastweek) or (firstweek | lastweek))]
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:django-danceschool    作者:django-danceschool    | 项目源码 | 文件源码
def readable_weekday(weekday):
    try:
        return day_name[weekday]
    except (TypeError,IndexError):
        return None
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:alexa-apple-calendar    作者:zanderxyz    | 项目源码 | 文件源码
def get_date_desc(e):
    d = get_date(e)
    diff = d - datetime.datetime.today()
    if diff > datetime.timedelta(14):
        return d.strftime("%d %B")
    else:
        return calendar.day_name[d.weekday()]
项目:Pirka    作者:Mkohm    | 项目源码 | 文件源码
def get_day(self):
        """
        :return: The name of the weekday the event occurs
        """
        try:
            day = self.data["dayNum"]
            return calendar.day_name[day - 1]
        except:
            pass
项目:mr_meeseeks    作者:garr741    | 项目源码 | 文件源码
def dateFormatter(self, date):
      month = calendar.month_name[date.month]
      weekday = calendar.day_name[date.weekday()]
      day = date.day
      year = date.year
      results = str(weekday) + ", " + str(month) + " " + str(day) + ", " + str(year)
      return results
项目:covertutils    作者:operatorequals    | 项目源码 | 文件源码
def __generateDays() :

    def day_data(i):
        dayname = calendar.day_name[i]
        return [i, str( i ), dayname, dayname.lower(), dayname[:3], dayname[:3].lower()]

    return {i: day_data(i) for i in range(7)}
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:ksupcapp    作者:SkydiveK-State    | 项目源码 | 文件源码
def __str__(self):
        return self.event.title + " - " + calendar.day_name[self.date.weekday()]
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:empyrion-python-api    作者:huhlig    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:codewars    作者:AlekseiAQ    | 项目源码 | 文件源码
def day_and_time(mins):
    date = datetime(2017, 4, 23, 0, 0) + timedelta(minutes=mins)
    return "{} {:02}:{:02}".format(day_name[date.weekday()], date.hour, date.minute)
项目:pmatic    作者:LarsMichelsen    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:necrobot    作者:incnone    | 项目源码 | 文件源码
def str_full_12h(dt):
    if not dt:
        return ''

    weekday = calendar.day_name[dt.weekday()]
    day = dt.strftime("%d").lstrip('0')
    hour = dt.strftime("%I").lstrip('0')
    pm_str = dt.strftime("%p").lower()
    datestr = dt.strftime("%b {0} @ {1}:%M{2} %Z".format(day, hour, pm_str))
    return weekday + ', ' + datestr
项目:necrobot    作者:incnone    | 项目源码 | 文件源码
def str_full_24h(dt):
    if not dt:
        return ''

    weekday = calendar.day_name[dt.weekday()]
    day = dt.strftime("%d").lstrip('0')
    hour = dt.strftime("%H").lstrip('0')
    if hour == '':
        hour = '00'
    datestr = dt.strftime("%b {0} @ {1}:%M %Z".format(day, hour))
    return weekday + ', ' + datestr
项目:necrobot    作者:incnone    | 项目源码 | 文件源码
def str_dateonly(dt):
    weekday = calendar.day_name[dt.weekday()]
    day = dt.strftime("%d").lstrip('0')
    return dt.strftime("{0}, %b {1}".format(weekday, day))
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday
项目:slackbot    作者:cybernetisk    | 项目源码 | 文件源码
def repo(message):
    from datetime import date
    import calendar
    my_date = date.today()
    day = calendar.day_name[my_date.weekday()]

    if(day == 'Tuesday'):
        message.reply('Ja')
    else:
        message.replay('Nei')
项目:slackbot    作者:cybernetisk    | 项目源码 | 文件源码
def repo(message):
    from datetime import date
    import calendar
    my_date = date.today()
    day = calendar.day_name[my_date.weekday()]

    if(day == 'Tuesday'):
        message.reply('Ja')
    else:
        message.replay('Nei')
项目:slackbot    作者:cybernetisk    | 项目源码 | 文件源码
def repo(message):
    from datetime import date
    import calendar
    my_date = date.today()
    day = calendar.day_name[my_date.weekday()]

    if(day == 'Monday'):
        message.reply('Ja')
    else:
        message.reply('Nei')
项目:takeout-inspector    作者:cdubz    | 项目源码 | 文件源码
def talk_days(self):
        """Returns a stacked bar chart showing percentage of chats and emails on each day of the week.
        """
        c = self.conn.cursor()

        c.execute('''SELECT strftime('%w', `date`) AS dow,
            COUNT(CASE WHEN gmail_labels LIKE '%Chat%' THEN 1 ELSE NULL END) AS talk_messages,
            COUNT(CASE WHEN gmail_labels NOT LIKE '%Chat%' THEN 1 ELSE NULL END) AS email_messages
            FROM messages
            WHERE dow NOTNULL
            GROUP BY dow;''')

        talk_percentages = OrderedDict()
        talk_messages = OrderedDict()
        email_percentages = OrderedDict()
        email_messages = OrderedDict()
        for row in c.fetchall():
            dow = calendar.day_name[int(row[0]) - 1]  # sqlite strftime() uses 0 = SUNDAY.
            talk_percentages[dow] = str(round(float(row[1]) / sum([row[1], row[2]]) * 100, 2)) + '%'
            email_percentages[dow] = str(round(float(row[2]) / sum([row[1], row[2]]) * 100, 2)) + '%'
            talk_messages[dow] = row[1]
            email_messages[dow] = row[2]

        chats_trace = pgo.Bar(
            x=talk_messages.keys(),
            y=talk_messages.values(),
            text=talk_percentages.values(),
            name='Chat messages',
            marker=dict(
                color=self.config.get('color', 'primary'),
            ),
        )
        emails_trace = pgo.Bar(
            x=email_messages.keys(),
            y=email_messages.values(),
            text=email_percentages.values(),
            name='Email messages',
            marker=dict(
                color=self.config.get('color', 'secondary'),
            ),
        )

        layout = plotly_default_layout_options()
        layout['barmode'] = 'stack'
        layout['margin'] = pgo.Margin(**layout['margin'])
        layout['title'] = 'Chat (vs. Email) Days'
        layout['xaxis']['title'] = 'Day of the week'
        layout['yaxis']['title'] = 'Messages exchanged'

        return plotly_output(pgo.Figure(data=[chats_trace, emails_trace], layout=pgo.Layout(**layout)))