#Auther : vivek sharma
#date : 06-11-2006
#Description : This script is used to get the list of week in given year, user have to input the year ,
def WeekFinderFromYear(year):
""" will return all the week from selected year """
import datetime
WEEK = {'MONDAY':0,'TUESDAY':1,'WEDNESDAY':2,'THURSDAY':3,'FRIDAY':4,'SATURDAY':5,'SUNDAY':6}
MONTH = {'JANUARY':1,'FEBRUARY':2,'MARCH':3,'APRIL':4,'MAY':5,'JUNE':6,'JULY':7,'AUGUST':8,'SEPTEMBER':9,'OCTOBER':10,'NOVEMBER':11,'DECEMBER':12}
year=int(year)
month= MONTH['JANUARY']
day=WEEK['MONDAY']
dt = datetime.date(year,month,1)
dow_lst = []
while dt.weekday() != day:
dt = dt + datetime.timedelta(days=1)
lst_month = MONTH.values()
lst_month.sort()
for mont in lst_month:
while dt.month == mont:
dow_lst.append(dt)
dt = dt + datetime.timedelta(days=7)
#for each in dow_lst:
# print each
return dow_lst
year=raw_input("Enter the year:")
week_list = WeekFinderFromYear(year)
for each in week_list:
print each
sharma_vivek82 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.