当前位置: 首页>>代码示例>>Python>>正文


Python Week.monday方法代码示例

本文整理汇总了Python中isoweek.Week.monday方法的典型用法代码示例。如果您正苦于以下问题:Python Week.monday方法的具体用法?Python Week.monday怎么用?Python Week.monday使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在isoweek.Week的用法示例。


在下文中一共展示了Week.monday方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_p

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import monday [as 别名]
def make_p(current_year_num, begin_week_num):
  current_week = Week(current_year_num, begin_week_num)
  commit(current_week.monday())
  commit(current_week.tuesday())
  commit(current_week.wednesday())
  commit(current_week.thursday())
  commit(current_week.friday())
  current_week = Week(current_year_num, begin_week_num + 1 )
  commit(current_week.monday())
  commit(current_week.wednesday())
  current_week = Week(current_year_num, begin_week_num + 2 )
  commit(current_week.monday())
  commit(current_week.wednesday())
  current_week = Week(current_year_num, begin_week_num + 3 )
  commit(current_week.monday())
  commit(current_week.tuesday())
  commit(current_week.wednesday())
开发者ID:jackfischer,项目名称:git-prank,代码行数:19,代码来源:git-prank.py

示例2: _task_completed

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import monday [as 别名]
def _task_completed(user_id, task_id, year, week_number):
    
    """ Return true if a task is completed for this specific user and week """
    
    week = Week(year, week_number)
    monday = week.monday().isoformat()
    next_monday = week.sunday() + timedelta(days=1)
    return _db.is_task_completed(user_id, task_id, monday, next_monday)
开发者ID:dagheyman,项目名称:cleaning-week,代码行数:10,代码来源:server.py

示例3: test_days

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import monday [as 别名]
    def test_days(self):
        w = Week(2011, 20)
        self.assertEqual(w.monday().isoformat(),    "2011-05-16")
        self.assertEqual(w.tuesday().isoformat(),   "2011-05-17")
        self.assertEqual(w.wednesday().isoformat(), "2011-05-18")
        self.assertEqual(w.thursday().isoformat(),  "2011-05-19")
        self.assertEqual(w.friday().isoformat(),    "2011-05-20")
        self.assertEqual(w.saturday().isoformat(),  "2011-05-21")
        self.assertEqual(w.sunday().isoformat(),    "2011-05-22")

        self.assertEqual(w.day(0).isoformat(),  "2011-05-16")
        self.assertEqual(w.day(-1).isoformat(), "2011-05-15")
        self.assertEqual(w.day(10).isoformat(), "2011-05-26")

        days = w.days()
        self.assertEqual(len(days), 7)
        self.assertEqual(days[0].isoformat(), "2011-05-16")
        self.assertEqual(days[-1].isoformat(), "2011-05-22")

        from datetime import date
        self.assertFalse(w.contains(date(2011,5,15)))
        self.assertTrue(w.contains(date(2011,5,16)))
        self.assertTrue(w.contains(date(2011,5,22)))
        self.assertFalse(w.contains(date(2011,5,23)))
开发者ID:Zopieux,项目名称:isoweek,代码行数:26,代码来源:test_isoweek.py

示例4: for_week

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import monday [as 别名]
 def for_week(self, year, week_no):
     from isoweek import Week
     week = Week(year, week_no)
     return TimeEntry.objects.filter(date__gte=week.monday(), date__lte=week.sunday())
开发者ID:andrewboltachev,项目名称:weakly_reports,代码行数:6,代码来源:models.py

示例5: int

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import monday [as 别名]
    sys.exit(0)

if infoboks.has_param(commonargs['year']) and infoboks.has_param(commonargs['week']):
    year = int(re.sub(ur'<\!--.+?-->', ur'', unicode(infoboks.parameters[commonargs['year']])).strip())
    startweek = int(re.sub(ur'<\!--.+?-->', ur'', unicode(infoboks.parameters[commonargs['week']])).strip())
    if infoboks.has_param(commonargs['week2']):
        endweek = re.sub(ur'<\!--.+?-->', ur'', unicode(infoboks.parameters[commonargs['week2']])).strip()
        if endweek == '':
            endweek = startweek
    else:
        endweek = startweek
    endweek = int(endweek)

    startweek = Week(year, startweek)
    endweek = Week(year, endweek)
    start = wiki_tz.localize(datetime.combine(startweek.monday(), dt_time(0, 0, 0)))
    end = wiki_tz.localize(datetime.combine(endweek.sunday(), dt_time(23, 59, 59)))
elif infoboks.has_param(ibcfg['start']) and infoboks.has_param(ibcfg['end']):
    startdt = infoboks.parameters[ibcfg['start']].value
    enddt = infoboks.parameters[ibcfg['end']].value
    start = wiki_tz.localize(datetime.strptime(startdt + ' 00 00 00', '%Y-%m-%d %H %M %S'))
    end = wiki_tz.localize(datetime.strptime(enddt + ' 23 59 59', '%Y-%m-%d %H %M %S'))
else:
    log('!! fant ikke datoer')
    sys.exit(0)

year = start.isocalendar()[0]
startweek = start.isocalendar()[1]
endweek = end.isocalendar()[1]

figname = config['plot']['figname'] % {'year': year, 'week': startweek}
开发者ID:jhsoby,项目名称:UKBot,代码行数:33,代码来源:uploadplot.py

示例6: normalize_record

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import monday [as 别名]
def normalize_record(r):
    date = datetime.strptime(r['Date'], "%Y-%m-%d")
    weekday = date.weekday()
    r['NowDayFromStart'] = (date - START_DATE).days
    r['NowDayOfWeek'] = int(weekday)
    r['NowDayOfMonth'] = int(date.day)
    r['NowMonth'] = int(date.month)
    r['NowYear'] = int(date.year)
    r['NowIsWeekend'] = int(weekday >= 5)
    r['NowWeek'] = int(date.date().isocalendar()[1])
    del r['Date'], r['DayOfWeek']

    r['Store'] = int(r['Store'])
    r['Promo'] = int(r['Promo'])
    r['SchoolHoliday'] = int(r['SchoolHoliday'])
    if 'Customers' in r:
        r['Customers'] = int(r['Customers'])
    if 'Sales' in r:
        r['Sales'] = int(r['Sales'])
    if 'Id' in r:
        r['Id'] = int(r['Id'])

    (
        r['IsOpenYes'],
        r['IsOpenNo'],
        r['IsOpenUnknown'],
    ) = one_hot_encode(r['Open'], ('1', '0', ''))
    del r['Open']

    (
        r['StateHolidayNone'],
        r['StateHolidayPublic'],
        r['StateHolidayEaster'],
        r['StateHolidayChristmas'],
    ) = one_hot_encode(r['StateHoliday'], ('0', 'a', 'b', 'c'))
    del r['StateHoliday']

    r['Promo2'] = int(r['Promo2'])
    r['CompetitionDistance'] = int(r['CompetitionDistance']) if r['CompetitionDistance'] else sys.maxint

    if r['CompetitionOpenSinceMonth'] and r['CompetitionOpenSinceYear']:
        competition_open_since = datetime(int(r['CompetitionOpenSinceYear']), int(r['CompetitionOpenSinceMonth']), 1)
        r['CompetitionOpenAvailable'] = 1
    else:
        competition_open_since = datetime(2010, 1, 1)
        r['CompetitionOpenAvailable'] = 0
    r['CompetitionOpenDays'] = int((date - competition_open_since).days)
    r['CompetitionOpenSinceMonth'] = int(competition_open_since.month)
    r['CompetitionOpenSinceYear'] = int(competition_open_since.year)

    (
        r['AssortmentBasic'],
        r['AssortmentExtra'],
        r['AssortmentExtended'],
    ) = one_hot_encode(r['Assortment'], ('a', 'b', 'c'))
    del r['Assortment']

    (
        r['StoreTypeA'],
        r['StoreTypeB'],
        r['StoreTypeC'],
        r['StoreTypeD'],
    ) = one_hot_encode(r['StoreType'], ('a', 'b', 'c', 'd'))
    del r['StoreType']

    if r['Promo2SinceYear'] and r['Promo2SinceWeek']:
        promo2_since = Week(int(r['Promo2SinceYear']), int(r['Promo2SinceWeek']))
        r['Promo2SinceAvailable'] = 1
    else:
        promo2_since = Week(2000, 1)
        r['Promo2SinceAvailable'] = 0
    promo2_since = datetime.combine(promo2_since.monday(), time(0, 0))
    r['Promo2RunDays'] = int((date - promo2_since).days)
    r['Promo2SinceWeek'] = int(promo2_since.date().isocalendar()[1])
    r['Promo2SinceMonth'] = int(promo2_since.month)
    r['Promo2SinceYear'] = int(promo2_since.year)
    del r['Promo2']

    (
        r['Promo2IntervalJanAprJulOct'],
        r['Promo2IntervalFebMayAugNov'],
        r['Promo2IntervalMarJunSepDec'],
    ) = one_hot_encode(r['PromoInterval'], tuple(PROMO2_INTERVAL))
    r['Promo2Now'] = int(r['NowMonth'] in PROMO2_INTERVAL.get(r['PromoInterval'], set()))
    del r['PromoInterval']
开发者ID:datanuggets,项目名称:kaggle_rossmann,代码行数:87,代码来源:normalize.py

示例7: plan_to_xml

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import monday [as 别名]
    def plan_to_xml(self):

        dateiname = "E" + str(self.__JG) + "_SG" + str(self.__SG) + "_KW_" + str(self.__KW) + ".xml"
        try:
            os.remove(dateiname)
        except:
            pass

        woche = Week(2015, self.__KW)
        print(woche)
        self.daten[1] = woche.monday().strftime("%d.%m.%Y")
        self.daten[2] = woche.tuesday().strftime("%d.%m.%Y")
        self.daten[3] = woche.wednesday().strftime("%d.%m.%Y")
        self.daten[4] = woche.thursday().strftime("%d.%m.%Y")
        self.daten[5] = woche.friday().strftime("%d.%m.%Y")

        implement = xml.dom.getDOMImplementation()
        doc = implement.createDocument(None, "Stundenplan", None)


        info_elem = doc.createElement("INFO")
        info_elem.setAttribute("KW", str(self.__KW))
        info_elem.setAttribute("JG", str(self.__JG))
        info_elem.setAttribute("SG", str(self.__SG))


        doc.documentElement.appendChild(info_elem)



        
        for i in range(5):

            i += 1

            tag_plan = self.__PLAN.get_tag(i)
            tag_elem = doc.createElement("Tag")
            tag_elem.setAttribute("Datum", self.daten[i])

            for i in range(10):
                i += 1
                stunde_elem = doc.createElement("Stunde")
                stunde_elem.setAttribute("stunde", str(i))
                stunde_elem.setAttribute("START", self.uhrzeiten_start[i])
                stunde_elem.setAttribute("END", self.uhrzeiten_ende[i])
                stunde_elem.setAttribute("AEND", str(tag_plan.get_unterricht(i)[3]))

                thema_elem = doc.createElement("Thema")
                thema_text = doc.createTextNode(tag_plan.get_unterricht(i)[0])
                thema_elem.appendChild(thema_text)

                dozent_elem = doc.createElement("Dozent")
                dozent_text = doc.createTextNode(tag_plan.get_unterricht(i)[1])
                dozent_elem.appendChild(dozent_text)

                raum_elem = doc.createElement("Raum")
                raum_text = doc.createTextNode(tag_plan.get_unterricht(i)[2])
                raum_elem.appendChild(raum_text)

                stunde_elem.appendChild(thema_elem)
                stunde_elem.appendChild(dozent_elem)
                stunde_elem.appendChild(raum_elem)
                tag_elem.appendChild(stunde_elem)
            doc.documentElement.appendChild(tag_elem)

        stri = doc.toprettyxml()
        datei = open(dateiname, "w")
        doc.writexml(datei, "\n", "  ")
        datei.close()

        root = etree.fromstring(stri)

        HTML(tree=root).write_pdf('weasyprint-website.pdf')
开发者ID:fastcrash,项目名称:PlanParser2,代码行数:75,代码来源:PlanFetcher.py


注:本文中的isoweek.Week.monday方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。