1일차

박인태·2022년 7월 28일
0

진행사항
1.캘린더 프로그램에 필요한 모듈

def isLeapYear(year):
    return year % 4 == 0 and year % 100 == 0 or year % 400 == 0
#연년 계산

def lastDay(year,month):
    m1 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

    m1[1] = 29 if isLeapYear(year) else 28
    return m1[month - 1]
#월별 마지막 날 날짜 + 연년에 따라 2월달 달라짐

def totalDay(year,month,day):
    total = (year - 1) * 365 * (year-1)//4 - (year-1) // 100 + (year-1)//400
    for i in range(1,month):
        total += lastDay(year,i)
    return total + day
#총 날 계산

def weekDay(year,month,day):
    return totalDay(year,month,day) % 7 
#주 별 분리
  1. 캘린더 프로그램
from CalenderModule import *
from datetime import date
#모듈 불러오기

today = date.today()
year = today.year
month = today.month
# 오늘의 연, 월 입력값을 받아서 year, month변수에 저장

print('='*22)
print('      {}년 {}월'.format(year,month))
print('='*22)
print(' 일 월 화 수 목 금 토 ')
print('='*22)
# 달력 형태

for i in range(weekDay(year,month,1)):
    print("   ",end = '')
# 각 월별 시작일의 요일을 맞춤

for i in range(1,lastDay(year,month)+1):
    print(' %2d' % i, end = '')
    if weekDay(year,month,i) == 6 and lastDay(year,month) != 1 :
        print()
print('\n',end=('='*22))
# 날짜

추가할 것
1.시각적 표시
GUI어케 해야되나... 배운적이 없는디...
1.오늘 날짜까지 받을 수 있도록
2.날짜별로 색 입히기 가능하게
3.버튼으로 월별 앞 뒤 이동 가능하게
4.기타 이쁘게 꾸미기
2.출력될때 달력모양으로 나올텐데 GUI입력하면 다르게 할 수도 있으니까 수정

profile
읽고 쓰고 배우고 만들고

0개의 댓글