コード例 #1
0
ファイル: cal.py プロジェクト: matt-hayden/python-utilities
#! env python
"""
Very simply emulate UNIX cal program.
"""

from calendar import TextCalendar
from datetime import datetime
import sys

yearly = False

args=sys.argv[1:]
if args:
	if len(args)>1:
		month, year = int(args[0]), int(args[1])
	else:
		yearly = True
		year = int(args[0])
else:
	now=datetime.now()
	month, year = now.month, now.year

cal=TextCalendar()
if yearly:
	cal.pryear(year)
else:
	cal.prmonth(year, month)
コード例 #2
0
ファイル: calendar_ex.py プロジェクト: ys10002/AutomateIt
#Example of working with Calendar
import calendar
from calendar import TextCalendar
cal = TextCalendar()

#Returns the calender for the year 2017
cal.pryear(2017)

#Returns the calender for the month of Novemeber in 2017
cal.prmonth(2017, 11)

コード例 #3
0
#Example of working with Calendar
import calendar
from calendar import TextCalendar
cal = TextCalendar()

#Returns the calender for the year 2017
cal.pryear(2018)

#Returns the calender for the month of Novemeber in 2017
cal.prmonth(2018, 6)

コード例 #4
0
print(calendar.monthrange(2021,10))
print(calendar.monthcalendar(2019, 10))
print(calendar.prmonth(2021, 10))
print(calendar.prcal(2021))
print(calendar.day_name[0])
print(calendar.day_abbr[0])
print(calendar.month_name[1])
print(calendar.month_abbr[1])

print('--------------------------------')

c = Calendar()
print(list(c.itermonthdates(2021, 7)))
print(list(c.itermonthdays2(2020, 7)))
print(list(c.itermonthdays3(2021, 7)))
print(list(c.itermonthdays4(2021, 7)))

print('--------------------------------')

tx = TextCalendar()
print(tx.formatmonth(2021, 9))
print(tx.prmonth(2021, 9))
print(tx.formatyear(2021))
print(tx.pryear(2021))

print('---------------------------------')

hc = HTMLCalendar()
print(hc.formatmonth(2021, 10))
print(hc.formatyear(2021))
print(hc.formatyearpage(2021))