Long year: Difference between revisions

m (→‎{{header|Phix}}: added syntax colouring, marked p2js compatible)
Line 369:
 
 
=={{header|BASIC256BASIC}}==
 
==={{header|ASIC}}===
{{trans|Commodore BASIC}}
<lang basic>
REM Long year
CLS
PRINT "**** List of ISO long years ****"
PRINT "Start year";
INPUT S
PRINT "End year";
INPUT E
PRINT
FOR Y = S TO E
GOSUB CALCLY:
IF LY <> 0 THEN
PRINT Y;
ENDIF
NEXT Y
PRINT
END
 
CALCLY:
REM Nonzero if Y is long
LY = 0
AY = Y
GOSUB CALCWD:
IF WD = 4 THEN
LY = -1
ENDIF
AY = Y - 1
GOSUB CALCWD:
IF WD = 3 THEN
LY = -1
ENDIF
RETURN
 
CALCWD:
REM Weekday of AY-12-31, 0 = Sunday
WD = AY
TMP = AY / 4
WD = WD + TMP
TMP = AY / 100
WD = WD - TMP
TMP = AY / 400
WD = WD + TMP
WD = WD MOD 7
RETURN
</lang>
{{out}}
<pre>
**** List of ISO long years ****
Start year?1995
End year?2045
 
1998 2004 2009 2015 2020 2026 2032 2037 2043
</pre>
 
==={{header|BASIC256}}===
<lang BASIC256>function p(y)
return (y + int(y/4) - int(y/100) + int(y/400)) mod 7
Line 401 ⟶ 459:
2093
2099</pre>
 
 
=={{header|BBC BASIC}}==
Anonymous user