-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalender.f
85 lines (77 loc) · 2.17 KB
/
Calender.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
c234567
program calnder
implicit none
integer date, day, mon, year, def
integer year2, mon2, day2, day3
integer chk1, chk2, chk3, diff, dow
logical leap
c 1900년 1월 1일은 월요일이다.
print *, 'input the year, month, day'
read (*,*) year,mon,day
year2=year-1900
mon2=mon-1
day2=day-1
c 1년이 365일이고 윤년고려(4년에 한번, 40년에 한번 x, 400년에 한번)
chk1=(year/4)-475
chk2=(year/100)-19
chk3=(year/400)-4
leap = .FALSE.
If (mod(year, 4) .EQ. 0) then
leap = .TRUE.
If (mod(year, 100) .EQ. 0) then
leap = .FALSE.
If (mod(year, 400) .EQ. 0) then
leap = .TRUE.
else
end if
else
end if
else
end if
print *, 'Leap year', chk1-chk2+chk3
diff=(year2*365)+chk1-chk2+chk3
c 1,3,5,7,8,10,12월은 31일
c 4,6,9,11월은 30일
c 2월은 29일 or 28일(윤년만)
If (mon2 .GE. 0) then
If (mon2 .GE. 1) diff=diff+31
if (mon2 .GE. 2) then
If (leap .EQ. .TRUE.) then
diff=diff+29
else
diff=diff+28
end if
end if
if (mon2 .GE. 3) diff=diff+31
if (mon2 .GE. 4) diff=diff+30
if (mon2 .GE. 5) diff=diff+31
if (mon2 .GE. 6) diff=diff+30
if (mon2 .GE. 7) diff=diff+31
if (mon2 .GE. 8) diff=diff+31
if (mon2 .GE. 9) diff=diff+30
if (mon2 .GE. 10) diff=diff+31
if (mon2 .GE. 11) diff=diff+30
else
end if
c 날짜 더함
diff=diff+day2
c 요일 계산
print*, diff
dow=mod(diff, 7)
If (dow .EQ. 0) then
print *, 'Monday'
else if (dow .EQ. 1) then
print *, 'Tuesday'
else if (dow .EQ. 2) then
print *, 'Wednsday'
else if (dow .EQ. 3) then
print *, 'Thursday'
else if (dow .EQ. 4) then
print *, 'Friday'
else if (dow .EQ. 5) then
print *, 'Saturday'
else
print *, 'Sunday'
end if
stop
end