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


Python Calendar.itermonthdays方法代码示例

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


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

示例1: render_month

# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import itermonthdays [as 别名]
    def render_month (self, x,y, month_no):
        svg = ''        
    
        svg += '<g>'
        svg += '<text x="%smm" y="%smm" font-family="\'%s\'" font-size="%smm" text-anchor="middle" fill="%s">'% (x + self.style['month-width']/2,y+self.style['month-padding-top'], self.style['month-font-family'], self.style['month-font-size'], self.style['month-color'])
        svg += '%s' % (self.month_names [month_no-1])
        svg += '</text>'
        svg += self.render_week (x, y+self.style['week-padding-top'])
        
        day_of_week = -1 # will start from Monday
        week_no = 0        

        c = Calendar (0)        
        for day_no in c.itermonthdays (self.year, month_no):

            day_of_week = (day_of_week + 1) % 7
            if day_of_week == 0: week_no += 1
            
            if day_no == 0: continue # month not yet started
            
            xx = x + self.style['day-width'] * (day_of_week)
            yy = y + self.style['day-padding-top'] + week_no * self.style['day-height']
            
            svg += self.render_day (xx, yy, month_no, day_no, day_of_week)
        
        svg += '</g>'
        return svg
开发者ID:mr-bin,项目名称:scripts,代码行数:29,代码来源:svg_calendar.py

示例2: show_month

# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import itermonthdays [as 别名]
def show_month(tm):
    (ly, lm, ld) = get_lunar_date(tm)
    print
    print u"%d年%d月%d日" % (tm.year, tm.month, tm.day), week_str(tm), 
    print u"\t农历:", y_lunar(ly), m_lunar(lm), d_lunar(ld)
    print
    print u"日\t一\t二\t三\t四\t五\t六"

    c = Cal()
    ds = [d for d in c.itermonthdays(tm.year, tm.month)]
    count = 0
    for d in ds:
        count += 1
        if d == 0:
            print "\t",
            continue

        (ly, lm, ld) = get_lunar_date(datetime(tm.year, tm.month, d))
        if count % 7 == 0:
            print

        d_str = str(d)
        if d == tm.day:
            d_str = u"*" + d_str
        print d_str + d_lunar(ld) + u"\t",
    print
开发者ID:niu2x,项目名称:birthday,代码行数:28,代码来源:lunar.py

示例3: month_sales

# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import itermonthdays [as 别名]
	def month_sales(self,farm):
		'''This function returns the monthly sales'''
		date = datetime.date.today()
		cal = Calendar()
		days_month=list(set(list(cal.itermonthdays(date.year, date.month)))-set([0]))
		orders = PurchaseOrder.objects.filter(farm=farm,date__month=date.month,date__year=date.year)
		products=PurchaseOrder.objects.product_order_month(farm,date)
		total_day=[]
		count_sales=[]
		for day in days_month:
			total_day.append(0)
			count_sales.append(0)
		total_month=0
		total_products = PurchaseOrder.objects.count_products_month(farm,date)
		for order in orders:
			for idx,day in enumerate(days_month):
				if order.date.day==day:
					total = order.total_order
					t_products = order.quantity
					if total_day[idx]!=0:
						price  = total_day[idx]+total
						total_day[idx]=price
						total_month+=total
						count = count_sales[idx]
						count_sales[idx]=(count+t_products)
					else:
						total_month+=total
						total_day[idx]=total
						count_sales[idx]=(t_products)

					break
		data = {'labels':days_month, 'values':total_day, 'count':count_sales, 'total_month':total_month, 'total_products':total_products, 'products':products}
		return data
开发者ID:aramakao,项目名称:ceres,代码行数:35,代码来源:models.py

示例4: getdayslist

# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import itermonthdays [as 别名]
def getdayslist():
    # 日時の準備(とりあえず先月で)
    import datetime
    from dateutil.relativedelta import relativedelta
    from calendar import Calendar

    prev = datetime.date.today() - relativedelta(months=1)
    cal = Calendar(firstweekday=6)
    dayslist = []
    for d in cal.itermonthdays(prev.year, prev.month):
        if d != 0:
            dayslist.append("%d%d%02d" % (prev.year, prev.month, d))
    return dayslist
开发者ID:YOwatari,项目名称:ResearchScript,代码行数:15,代码来源:get_bookmarks.py

示例5: getPrimeDays

# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import itermonthdays [as 别名]
def getPrimeDays(year):
    p = PrimesGenerator()

    primes = []
    cal = Calendar()
    multiple = int("1" + "0"*(len(str(year))))
    for month in range(1, 12):
        for day in cal.itermonthdays(year, month):
            # itermonthdays tacks on (to the month front/back) days necessary to get a full week, all represented as 0's
            if day is 0:
                continue

            num = month*100*multiple + day*multiple + year
            if p.checkPrime(num):
                primes.append("%(month)s/%(day)s/%(year)s" % {"month": month, "day": day, "year": year})

    return primes
开发者ID:bafulton,项目名称:Primes,代码行数:19,代码来源:primes.py

示例6: getDays_with_lunar

# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import itermonthdays [as 别名]
def getDays_with_lunar(year, month, day):
    """根据年月日获得农历日期,与其月日一致的日期的公历"""
    (lyear, lmonth, lday) = get_ludar_date(datetime(year, month, day))
    #print(str(year) + '-' + str(month) + '-' + str(day) + ':' + y_lunar(lyear) + m_lunar(lmonth) + d_lunar(lday))
    days = []
    y = 2012
    c = Cal()
    while True:
        if y >= END_YEAR:
            break
        for m in xrange(1, 13):
            ds = [d for d in c.itermonthdays(y, m)]
            for d in ds:
                if d == 0:
                    continue
                (ly, lm, ld) = get_ludar_date(datetime(y, m, d))
                if (lmonth == lm) and (lday == ld):
                    print(str(y) + '-' + str(m) + '-' + str(d) + ':' + y_lunar(ly) + m_lunar(lm) + d_lunar(ld))
                    days.append((y, m, d))
        y += 1
    return days
开发者ID:grimtraveller,项目名称:utocode,代码行数:23,代码来源:pylunar.py

示例7: fnGlob

# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import itermonthdays [as 别名]
def fnGlob(fn, langs=[], year=util.gmtnow().year):
  """
  transforms parameters to remote url filename scheme w/ parameters
  """
  remote = []

  # replace lang w/ available langs
  i = fn.find('$lang')
  dot = fn.rfind('.')
  if i>=0:
    (bef, sep, aft) = fn.partition('$lang')
    for lang in langs:
      remote.append(''.join([bef, '?lang=', lang, aft]))

  # replace $date with dates in year
  i = fn.find('$date')
  if i>=0:
    cal = Calendar()
    today =  util.gmtnow()
    for i in range(0, len(remote)):
			# extract part of string before $date
      rbef = remote.pop(0).split('$date')[0]
      for month in range(1, 13):
        for day in cal.itermonthdays(year, month):
          if (0 == day): continue # don't know why, but day is 0 sometimes
          # we are not interested in older events
          if (year < today.year): continue
          if (year == today.year and month < today.month): continue
          # if (year == today.year and month == today.month \
					# 		and day < today.day): continue
          remote.append('%s&year=%i&month=%i&day=%i' % \
            (rbef, year, month, day))

  # when no expansion happened at all, simply add the original string
  if 1 > len(remote):
    remote.append(fn)

  return remote
开发者ID:panterch,项目名称:mapsagenda,代码行数:40,代码来源:static.py

示例8: make_calendar

# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import itermonthdays [as 别名]
def make_calendar(year, month, firstweekday="Mon"):
    firstweekday = list(day_abbrs).index(firstweekday)
    calendar = Calendar(firstweekday=firstweekday)

    month_days  = [ None if not day else str(day) for day in calendar.itermonthdays(year, month) ]
    month_weeks = len(month_days)//7

    workday = "linen"
    weekend = "lightsteelblue"

    def weekday(date):
        return (date.weekday() - firstweekday) % 7

    def pick_weekdays(days):
        return [ days[i % 7] for i in range(firstweekday, firstweekday+7) ]

    day_names = pick_weekdays(day_abbrs)
    week_days = pick_weekdays([workday]*5 + [weekend]*2)

    source = ColumnDataSource(data=dict(
        days            = list(day_names)*month_weeks,
        weeks           = sum([ [str(week)]*7 for week in range(month_weeks) ], []),
        month_days      = month_days,
        day_backgrounds = sum([week_days]*month_weeks, []),
    ))

    holidays = [ (date, summary.replace("(US-OPM)", "").strip()) for (date, summary) in us_holidays
        if date.year == year and date.month == month and "(US-OPM)" in summary ]

    holidays_source = ColumnDataSource(data=dict(
        holidays_days  = [ day_names[weekday(date)] for date, _ in holidays ],
        holidays_weeks = [ str((weekday(date.replace(day=1)) + date.day) // 7) for date, _ in holidays ],
        month_holidays = [ summary for _, summary in holidays ],
    ))

    xdr = FactorRange(factors=list(day_names))
    ydr = FactorRange(factors=list(reversed([ str(week) for week in range(month_weeks) ])))
    x_scale, y_scale = CategoricalScale(), CategoricalScale()

    plot = Plot(x_range=xdr, y_range=ydr, x_scale=x_scale, y_scale=y_scale,
                plot_width=300, plot_height=300, outline_line_color=None)
    plot.title.text = month_names[month]
    plot.title.text_font_size = "12pt"
    plot.title.text_color = "darkolivegreen"
    plot.title.offset = 25
    plot.min_border_left = 0
    plot.min_border_bottom = 5

    rect = Rect(x="days", y="weeks", width=0.9, height=0.9, fill_color="day_backgrounds", line_color="silver")
    plot.add_glyph(source, rect)

    rect = Rect(x="holidays_days", y="holidays_weeks", width=0.9, height=0.9, fill_color="pink", line_color="indianred")
    rect_renderer = plot.add_glyph(holidays_source, rect)

    text = Text(x="days", y="weeks", text="month_days", text_align="center", text_baseline="middle")
    plot.add_glyph(source, text)

    xaxis = CategoricalAxis()
    xaxis.major_label_text_font_size = "8pt"
    xaxis.major_label_standoff = 0
    xaxis.major_tick_line_color = None
    xaxis.axis_line_color = None
    plot.add_layout(xaxis, 'above')

    hover_tool = HoverTool(renderers=[rect_renderer], tooltips=[("Holiday", "@month_holidays")])
    plot.tools.append(hover_tool)

    return plot
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:70,代码来源:calendars.py


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