Creation of a garbage collection calendar
It is a garbage collection calendar of the all year by a
self-governing body etc.
The day of garbage collection is as follows.
It works in the terminal on Mac OS X 10.7.5.
The Python 2.7.1 is used on the script.
Below, the garbage collection calendar of 2013 editions is created.
$ python garbage_collection_day.py 2013 > manytime-1.txt
garbage_collection_day.py:
self-governing body etc.
The day of garbage collection is as follows.
1: 2nd Monday Collection of Waste Articles by Children's Association 2: 4th Monday Large-sized Combustible Trash 3: Every Week Tuesday Common Garbage 4: 1st Thursday Recycling Garbage 5: 2nd Thursday Incombustible Trash 6: 3rd Thursday Recycling Garbage 7: Every Week Friday Common Garbage
It works in the terminal on Mac OS X 10.7.5.
The Python 2.7.1 is used on the script.
Below, the garbage collection calendar of 2013 editions is created.
$ python garbage_collection_day.py 2013 > manytime-1.txt
garbage_collection_day.py:
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import calendar # Creation of the start time string. def startTime(dayStr, num): # aHour = 0 # if len(str(aHour)) == 1: aHourStr = " 0" + str(aHour) else: aHourStr = " " + str(aHour) # return dayStr + aHourStr + ":00:00" # Creation of the end time string. def endTime(dayStr, num): # aHour = 23 # if len(str(aHour)) == 1: aHourStr = " 0" + str(aHour) else: aHourStr = " " + str(aHour) # return dayStr + aHourStr + ":59:00" # Creation of the yyyy-MM-dd string def yyyyMMdd(year,month,day): # if len(str(month)) == 1: aMonthStr = "0" + str(month) else: aMonthStr = "" + str(month) # if len(str(day)) == 1: aDayStr = "0" + str(day) else: aDayStr = "" + str(day) # return str(year_num) + "-" + aMonthStr + "-" + aDayStr # Creation of the data for ManyTime. def tajikan(aDayStr,aComment): startStr = startTime(aDayStr,0) endStr = endTime(aDayStr,0) return startStr + "\t" + endStr + "\t" + aComment # Handling the argument argvs = sys.argv argc = len(argvs) # Check the argument if (argc != 2): print 'Usage: # python %s year_num' % argvs[0] quit() # Start main program year_num = int(argvs[1]) # Processing on a monthly basis. for month in range(1, 13): # Get the calendar. c = calendar.monthcalendar(year_num, month) # Processing on a weekly basis. for week in range(0,len(c)): aWeek = c[week] # Output 2nd Monday and 4th Monday. aDay1 = aWeek[calendar.MONDAY] if aDay1 != 0: # 2nd Monday if week == 2: dayStr = yyyyMMdd(year_num,month,aDay1) print tajikan(dayStr,"Collection of Waste Articles by Children's Association") # 4th Monday if week == 4: dayStr = yyyyMMdd(year_num,month,aDay1) print tajikan(dayStr,"Large-sized Combustible Trash") # Output every Tuesday aDay2 = aWeek[calendar.TUESDAY] if aDay2 != 0: #print '%3s: %2s *' % (month, aDay1) dayStr = yyyyMMdd(year_num,month,aDay2) #print startTime(dayStr,0) print tajikan(dayStr,"Common Garbage") # Output 1st Thursday, 2nd Thursday and 3rd Thursday. aDay4 = aWeek[calendar.THURSDAY] if aDay4 != 0: # 1st Thursday if week == 1: dayStr = yyyyMMdd(year_num,month,aDay4) print tajikan(dayStr,"Recycling Garbage") # 2nd Thursday if week == 2: dayStr = yyyyMMdd(year_num,month,aDay4) print tajikan(dayStr,"Incombustible Trash") # 3rd Thursday if week == 3: dayStr = yyyyMMdd(year_num,month,aDay4) print tajikan(dayStr,"Recycling Garbage") # Output every Friday. aDay5 = aWeek[calendar.FRIDAY] if aDay5 != 0: #print '%3s: %2s' % (month, aDay2) dayStr = yyyyMMdd(year_num,month,aDay5) #print startTime(dayStr,0) print tajikan(dayStr,"Common Garbage") # End main program
2013-05-04 01:28