Dia de la Semana de una fecha

      

   




El mismo programa en Quick Basic (QB64)


Dim UserDate As String
Dim Day As Integer
Dim Month As Long
Dim Year As Long
Dim NewYear As String
Dim DMY As Integer
Dim Century As Integer
Dim Weekday As String
Dim TxtDay(7) As String
Dim TxtMonth(12) As String
Dim Suffix As String

Data Domingo,lunes,Martes,Miercoles,Jueves,Viernes,Sabado
Data Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio
Data Agosto,Septiembre,Octubre,Noviembre,Diciembre

For Count = 0 To 6
    Read TxtDay(Count)
Next Count
For Count = 0 To 11
    Read TxtMonth(Count)
Next Count

Do
    Cls
    Locate 10, 28
    Print "Introduzca Fecha:"
    Locate 12, 20
    Print "en Formato DD MM YYYY"
    Locate 15, 33
    Line Input ; UserDate$
    If Len(UserDate$) = 0 Then End
Loop Until Len(UserDate$) = 10

'*** Separar el día, mes, año ***

Day = Val(Left$(UserDate$, 2))
Month = Val(Mid$(UserDate$, 4, 2))
Year = Val(Right$(UserDate$, 4))

'*** iniciar la impresión

Suffix$ = "th"
If Day Mod 10 = 1 Then Suffix$ = "st"
If Day Mod 10 = 2 Then Suffix$ = "nd"
If Day Mod 10 = 3 Then Suffix$ = "rd"
If Day > 10 And Day < 14 Then Suffix = "th"

Locate 18, 21
Print RTrim$(Str$(Day)); " de "; TxtMonth$(Month - 1); Year; "es ";

'*** Para cualquier fecha en enero o febrero agregue 12 al mes y
'*** restar 1 del año

If Month < 3 Then
    Month = Month + 12
    Year = Year - 1
End If

'*** Sumar 1 al mes y multiplicar por 2,61 '*** Suelta la fracción (no redonda) después

Month = Month + 1
Month = Fix(Month * 2.61)

'*** Agregar día, mes y los dos últimos dígitos del año

NewYear$ = LTrim$(Str$(Year))
Year = Val(Right$(NewYear$, 2))
DMY = Day + Month + Year
Century = Val(Left$(NewYear$, 2))

'*** Suma una cuarta parte de los dos últimos dígitos del año '*** (truncado no redondeado)

Year = Fix(Year / 4)
DMY = DMY + Year

'*** Agregue los siguientes factores para el año

If Century = 18 Then Century = 2
If Century = 19 Then Century = 0
If Century = 20 Then Century = 6
If Century = 21 Then Century = 4
DMY = DMY + Century

'*** El día de la semana es el módulo de DMY dividido por 7

DMY = DMY Mod 7
Print TxtDay(DMY)

End

      Inicio Entrada antigua