Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
which day of the week
#1
This program is used to calculate the day of the week for any day starting from 1 AD.
Code: (Select All)
Code: (Select All)
Dim As Integer y, m, d
Dim a(1 To 12) As _Unsigned _Byte
Input "year,month,day"; y, m, d
If y < 1 Then
Print "Date of invalidity"
End
End If
Data 31,28,31,30,31,30,31,31,30,31,30,31
For i = 1 To 12
Read a(i)
Next i
For i = 1 To m - 1
s = s + a(i)
Next i
n$ = Str$(y)
If Right$(n$, 2) <> "00" Then
If y Mod 4 = 0 And m > 2 Then s = s + 1
Else
If y Mod 400 = 0 And m > 2 Then s = s + 1
End If

If y < 1582 Or (y = 1582 And m <= 10 And d <= 4) Then
y = y - 1
t = (y * 365 + y \ 4 + s + d) Mod 7
Select Case t
Case 0: Print "Friday"
Case 1: Print "Saturday"
Case 2: Print "Sunday"
Case 3: Print "Monday"
Case 4: Print "Tuesday"
Case 5: Print "Wednesday"
Case 6: Print "Thursday"
End Select
ElseIf y = 1582 And m = 10 And 4 < d And d < 15 Then
Print " The date does not exist"
ElseIf y > 1582 Or (y = 1582 And m >= 10 And d > 14) Then
y = y - 1
t = (y * 365 + (y \ 4 - (y \ 100 - y \ 400)) + s + d) Mod 7
Select Case t
Case 0: Print "Sunday"
Case 1: Print "Monday"
Case 2: Print "Tuesday"
Case 3: Print "Wednesday"
Case 4: Print "Thursday"
Case 5: Print "Friday"
Case 6: Print "Saturday"
End Select
End If
Reply


Messages In This Thread
which day of the week - by macalwen - 12-30-2024, 01:17 PM
RE: which day of the week - by SpriggsySpriggs - 12-30-2024, 03:12 PM
RE: which day of the week - by bplus - 12-30-2024, 03:16 PM
RE: which day of the week - by eoredson - 01-02-2025, 02:15 AM
RE: which day of the week - by Pete - 01-02-2025, 03:16 AM
RE: which day of the week - by bplus - 01-02-2025, 05:45 AM
RE: which day of the week - by bplus - 01-02-2025, 05:55 AM
RE: which day of the week - by SMcNeill - 01-02-2025, 06:18 AM
RE: which day of the week - by eoredson - 01-02-2025, 06:32 AM
RE: which day of the week - by bplus - 01-02-2025, 06:42 AM
RE: which day of the week - by eoredson - 01-02-2025, 07:14 AM
RE: which day of the week - by bplus - 01-02-2025, 07:25 AM
RE: which day of the week - by bplus - 01-02-2025, 07:33 AM
RE: which day of the week - by eoredson - 01-02-2025, 07:49 AM
RE: which day of the week - by eoredson - 01-02-2025, 08:13 AM
RE: which day of the week - by bplus - 01-02-2025, 08:18 AM
RE: which day of the week - by eoredson - 01-02-2025, 08:22 AM
RE: which day of the week - by Pete - 01-02-2025, 08:34 AM
RE: which day of the week - by bplus - 01-02-2025, 08:34 AM
RE: which day of the week - by SMcNeill - 01-02-2025, 10:44 AM
RE: which day of the week - by SpriggsySpriggs - 01-02-2025, 02:14 PM
RE: which day of the week - by SierraKen - 01-02-2025, 05:58 PM
RE: which day of the week - by bplus - 01-02-2025, 10:14 PM
RE: which day of the week - by Pete - 01-02-2025, 06:57 PM
RE: which day of the week - by macalwen - 01-05-2025, 11:51 AM
RE: which day of the week - by Pete - 01-06-2025, 01:48 AM



Users browsing this thread: 8 Guest(s)