RosettaCodeData/Task/Five-weekends/Harbour/five-weekends.harbour
2023-07-01 13:44:08 -04:00

34 lines
990 B
Text

PROCEDURE Main()
LOCAL y, m, d, nFound, cNames, nTot := 0, nNotFives := 0
LOCAL aFounds := {}
SET DATE ANSI
FOR y := 1900 TO 2100
nFound := 0 ; cNames := ""
FOR m := 1 TO 12
d := CtoD( hb_NtoS( y ) +"/" + hb_NtoS( m ) + "/1" )
IF CDoW( d ) == "Friday"
IF DaysInMonth( m ) == 31
nFound++
cNames += CMonth( d ) + " "
ENDIF
ENDIF
NEXT
IF nFound > 0
AAdd( aFounds, hb_NtoS( y ) + " : " + hb_NtoS( nFound ) + " ( " + Rtrim( cNames ) + " )" )
nTot += nFound
ELSE
nNotFives++
ENDIF
NEXT
? "Total months with five weekends: " + hb_NtoS( nTot )
? "(see bellow the first and last five years/months with five weekends)"
?
AEval( aFounds, { | e, n | Iif( n < 6, Qout( e ), NIL ) } )
Qout("...")
AEval( aFounds, { | e, n | Iif( n > Len(aFounds)-5, Qout( e ), NIL ) } )
?
? "Years with no five weekends months: " + hb_NtoS( nNotFives )
RETURN