Long year: Difference between revisions
m
syntax highlighting fixup automation
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
|||
Line 10:
{{trans|C++}}
<
F p(year)
R (year + (year I/ 4) - (year I/ 100) + (year I/ 400)) % 7
Line 17:
L(year) 2000..2100
I is_long_year(year)
print(year, end' ‘ ’)</
{{out}}
Line 25:
=={{header|Action!}}==
<
RETURN ((y+(y/4)-(y/100)+(y/400)) MOD 7)
Line 50:
LMARGIN=oldLMARGIN ;restore left margin on the screen
RETURN</
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Long_year.png Screenshot from Atari 8-bit computer]
Line 64:
=={{header|Ada}}==
The Ada calendar package handles dates for years 1901 through 2399. This program outputs all the long years within that range.
<
-- Calculate long years
-- Reference: https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year
Line 98:
end loop;
end Main;
</syntaxhighlight>
{{output}}
<pre>
Line 114:
=={{header|ALGOL 68}}==
{{Trans|ALGOL W}}
<
# finding years where 1st Jan or 31st Dec are Thursdays #
# returns the day of the week of the specified date (d/m/y), Sunday = 1 #
Line 137:
IF is long year( year ) THEN print( ( " ", whole( year, 0 ) ) ) FI
OD
END</
{{out}}
<pre>
Line 145:
=={{header|ALGOL-M}}==
<
COMMENT
Line 202:
END
</syntaxhighlight>
{{output}}
<pre>
Line 211:
=={{header|ALGOL W}}==
Uses the Day_of_week procedure from the Day_of_the_week task.
<
% this is equivalent to finding years where %
% 1st Jan or 31st Dec are Thursdays %
Line 236:
if isLongYear( year ) then writeon( I_W := 5, S_W := 0, year )
end for_year
end.</
{{out}}
<pre>
Line 243:
=={{header|APL}}==
<
isolongyear ← {(4 = dec31weekday ⍵) ∨ 3 = dec31weekday ⍵ - 1}</
{{Out}}
Line 255:
=={{header|AppleScript}}==
<
-- ISO8601 weeks begin on Mondays and belong to the year in which they have the most days.
-- A year which begins on a Thursday, or which begins on a Wednesday and is a leap year,
Line 272:
end repeat
return longYears</
{{output}}
Line 279:
On the other hand, since the cycle repeats every 400 years, it's possible to cheat with a precalculated look-up list:
<
return (y mod 400 is in {4, 9, 15, 20, 26, 32, 37, 43, 48, 54, 60, 65, 71, 76, 82, 88, 93, 99, 105, 111, 116, 122, 128, 133, 139, 144, 150, 156, 161, 167, 172, 178, 184, 189, 195, 201, 207, 212, 218, 224, 229, 235, 240, 246, 252, 257, 263, 268, 274, 280, 285, 291, 296, 303, 308, 314, 320, 325, 331, 336, 342, 348, 353, 359, 364, 370, 376, 381, 387, 392, 398})
end isLongYear
Line 288:
end repeat
return longYears</
=={{header|Arturo}}==
Line 294:
{{trans|Nim}}
<
date: to :date .format: "dd/MM/yyyy" ~"01/01/|year|"
Line 303:
print "Years with 53 weeks between 2000 and 2100:"
print select 2000..2100 => longYear?</
{{out}}
Line 311:
=={{header|AutoHotkey}}==
<
A := Mod(y + floor(y/4) - floor(y/100) + floor(y/400), 7)
y--, B := Mod(y + floor(y/4) - floor(y/100) + floor(y/400), 7)
return A=4 || B=3
}</
Examples:<
y := 1999+A_Index
res .= Long_year(y) ? Y " ": ""
}
MsgBox % "Long Years 2000-2100 : " res
return</
{{out}}
<pre>Long Years 2000-2100 : 2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099 </pre>
=={{header|AWK}}==
<syntaxhighlight lang="awk">
# syntax: GAWK -f LONG_YEAR.AWK
BEGIN {
Line 358:
return(0)
}
</syntaxhighlight>
{{out}}
<pre>
Line 373:
==={{header|Applesoft BASIC}}===
{{trans|Commodore BASIC}}
<
20 DEF FN WD(Y) = FN M7(Y + INT (Y / 4) - INT (Y / 100) + INT (Y / 400))
30 DEF FN LY(Y) = (4 = FN WD(Y)) OR (3 = FN WD(Y - 1))
Line 381:
70 PRINT : FOR Y = S TO E
80 IF FN LY(Y) THEN PRINT S$Y;:S$ = " "
90 NEXT Y</
==={{header|ASIC}}===
{{trans|Commodore BASIC}}
<
REM Long year
CLS
Line 428:
WD = WD MOD 7
RETURN
</syntaxhighlight>
{{out}}
<pre>
Line 439:
==={{header|BASIC256}}===
<
return (y + int(y/4) - int(y/100) + int(y/400)) mod 7
end function
Line 450:
if isLongYear(y) then print y
next y
end</
{{out}}
<pre>2004
Line 473:
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
<
REM The function as per specification.
Line 492:
NEXT
PRINT
ENDPROC</
{{out}}
<pre>
Line 501:
==={{header|Commodore BASIC}}===
<
110 DEF FNM7(N) = N - 7*INT(N / 7)
120 :
Line 518:
250 : IF FNLY(Y) THEN PRINT Y,
260 NEXT Y
270 PRINT</
{{Out}}
Line 533:
==={{Header|FreeBASIC}}===
<
return ( y + int(y/4) - int(y/100) + int(y/400) ) mod 7
end function
Line 545:
print islongyear(1998)
print islongyear(2020)
print islongyear(2021)</
{{out}}
<pre>
Line 554:
==={{header|GW-BASIC}}===
<
20 X = Y
30 GOSUB 100
Line 565:
100 P = X + INT(X/4) - INT(X/100) + INT(X/400)
110 P = P MOD 7
120 RETURN</
==={{header|IS-BASIC}}===
<
110 DEF RD(Y)=Y*365+INT(Y/4)-INT(Y/100)+INT(Y/400)
120 DEF LONGYEAR(Y)=(4=MOD(RD(Y),7)) OR(4=MOD((RD(Y-1)+1),7))
Line 576:
160 IF LONGYEAR(Y) THEN PRINT Y,
170 NEXT
180 PRINT</
==={{header|Nascom BASIC}}===
{{trans|Commodore BASIC}}
{{works with|Nascom ROM BASIC|4.7}}
<
10 REM Long year
20 REM FNM7(N)=MOD(N,7)
Line 602:
190 PRINT
200 END
</syntaxhighlight>
{{out}}
<pre>
Line 614:
==={{header|PureBasic}}===
{{trans|BASIC256}}
<
ProcedureReturn (y + Int(y/4) - Int(y/100) + Int(y/400)) % 7
EndProcedure
Line 631:
Print(""): Input()
CloseConsole()
EndIf</
{{out}}
<pre>
Line 643:
{{Works with|VB-DOS|1.0}}
Translated from Delphi
<syntaxhighlight lang="vb">
DEFINT A-Z
Line 675:
p% = (Yr + INT(Yr / 4) - INT(Yr / 100) + INT(Yr / 400)) MOD 7
END FUNCTION
</syntaxhighlight>
{{Out}}
<pre>
Line 689:
==={{header|S-Basic}}===
<syntaxhighlight lang="basic">
$lines
Line 738:
next year
end</
{{output}}
<pre>
Line 747:
==={{header|Tiny BASIC}}===
<
INPUT Y
LET X = Y
Line 762:
LET P = P - 7
GOTO 110
</syntaxhighlight>
{{out}}
<pre>
Line 776:
==={{header|True BASIC}}===
{{trans|BASIC256}}
<
FUNCTION isLongYear(y)
Line 791:
IF isLongYear(y) > 0 THEN PRINT y
NEXT y
END</
{{out}}
<pre>
Line 799:
==={{header|Yabasic}}===
{{trans|BASIC256}}
<
return mod((y + int(y/4) - int(y/100) + int(y/400)), 7)
end sub
Line 810:
if isLongYear(y) then print y : fi
next y
end</
{{out}}
<pre>
Line 817:
=={{header|BCPL}}==
<
let p(y) = (y + y/4 - y/100 + y/400) rem 7
Line 824:
let start() be
for y = 2000 to 2100
if longyear(y) do writef("%N*N", y)</
{{out}}
<pre>2004
Line 846:
=={{header|C sharp}}==
<
using System.Collections.Generic;
using System.Linq;
Line 863:
}
}</
{{out}}
<pre>
Line 870:
=={{header|C}}==
<
#include <math.h>
Line 897:
printf("\n");
return 0;
}</
{{out}}
Line 908:
=={{header|C++}}==
<
// https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year
Line 937:
std::cout << '\n';
return 0;
}</
{{out}}
Line 951:
=={{header|Clojure}}==
<
(-> (java.time.LocalDate/of year 12 28)
(.get (.weekOfYear (java.time.temporal.WeekFields/ISO)))
(= 53)))
(filter long-year? (range 2000 2100))</
{{out}}
<pre>
Line 963:
=={{header|CLU}}==
<
% we can hide the helper `p' in a cluster
Line 986:
end
end
end start_up</
{{out}}
<pre>2004
Line 1,009:
=={{header|Common Lisp}}==
<
(mod (+ year (floor year 4) (- (floor year 100)) (floor year 400)) 7))
Line 1,016:
(format t "Long years between 1800 and 2100:~&~a~%"
(loop for y from 1800 to 2100 if (iso-long-year-p y) collect y))</
{{Out}}
Line 1,028:
{{trans|Tcl}}
{{works with|GNU dc|1.3.95}}
<
[1q]s1
[1r- r 1r- * 1r-]sO # O = logical OR
Line 1,082:
[Long years between 1800 and 2100:]P AP
1800 2100 lDx
AP</
{{out}}
Line 1,098:
Note: The Library '''System.DateUtils''' implement a '''WeeksInYear''',but not working, return 52 always.
{{Trans|C++}}
<syntaxhighlight lang="delphi">
program Long_year;
Line 1,141:
Readln;
end.
</syntaxhighlight>
=={{header|Elixir}}==
<
def long_year?(y) do
{:ok, jan1} = Date.new(y,1,1)
Line 1,152:
end
IO.inspect(Enum.filter(1990..2050, &ISO.long_year?/1))</
{{Out}}
Line 1,159:
=={{header|Factor}}==
{{works with|Factor|0.99 2019-10-06}}
<
: long-year? ( n -- ? ) 12 28 <date> week-number 53 = ;
"Year Long?\n-----------" print 1990 2021 [a,b]
[ dup long-year? "yes" "no" ? "%d %s\n" printf ] each</
{{out}}
<pre style="height:45ex">
Line 1,204:
=={{header|Forth}}==
<
: long? ( year -- flag ) dup dec31wd 4 = if drop 1 else 1 - dec31wd 3 = if 1 else 0 then then ;
: demo ( startyear endyear -- ) cr swap do i long? if i . then loop cr ;</
{{Out}}
Line 1,214:
=={{header|Fortran}}==
<
program longyear
use iso_fortran_env, only: output_unit, input_unit
Line 1,252:
end function is_long_year
end program longyear
</syntaxhighlight>
{{out}}
Line 1,269:
=={{header|Go}}==
<
import (
Line 1,290:
fmt.Println(longYears)
}
}</
{{out}}
Line 1,305:
=={{header|Haskell}}==
<
import Data.Time.Calendar.WeekDate (toWeekDate)
Line 1,314:
main :: IO ()
main = mapM_ print $ filter longYear [2000 .. 2100]</
{{Out}}
<pre>2004
Line 1,337:
=={{header|J}}==
{{trans|C}}
<
ily =: (4=p) +. 3=p@:<:
ply =: (#~ ily)@:([ + 1+i.@:-~)</
{{out}}
<pre>
Line 1,347:
=={{header|Java}}==
<
import java.time.LocalDate;
import java.time.temporal.WeekFields;
Line 1,367:
}
</syntaxhighlight>
{{out}}
Line 1,376:
=={{header|JavaScript}}==
{{trans|TypeScript}}
<
const jan1 = new Date(year, 0, 1);
const dec31 = new Date(year, 11, 31);
Line 1,386:
console.log(y)
}
}</
{{Out}}
Line 1,404:
===Using Zeller's congruence===
<syntaxhighlight lang="jq">
# Use Zeller's Congruence to determine the day of the week, given
# year, month and day as integers in the conventional way.
Line 1,429:
"Long years from 1900 to 2100 inclusive:",
([range(1900;2101) | select(has53weeks)] | nwise(10) | join(", "))</
{{out}}
<pre>
Line 1,440:
===Using mktime and gmtime===
<
# with 0 for Sunday, 1 for Monday, etc
# $year $month $day are conventional
Line 1,455:
"Long years from 1900 to 2100 inclusive:",
([range(1900;2101) | select(has53weeks)] | nwise(10) | join(", "))</
{{out}}
As above.
=={{header|Julia}}==
<
has53weeks(year) = week(Date(year, 12, 28)) == 53
Line 1,468:
println(year, " ", has53weeks(year) ? "Yes" : "No")
end
</
<pre>
Year 53 weeks?
Line 1,507:
=={{header|Kotlin}}==
<syntaxhighlight lang="kotlin">
fun main() {
val has53Weeks = { year: Int -> LocalDate.of(year, 12, 28).get(WeekFields.ISO.weekOfYear()) == 53 }
Line 1,514:
.forEach { year -> print("$year ")}
}
</syntaxhighlight>
{{out}}
<pre style="height35ex">
Line 1,525:
=={{header|Logo}}==
{{works with|UCB Logo}}
<
output int quotient :x :y
end
Line 1,537:
end
for [y 1995 2045 1] [if iso_long_year? :y [print :y]]</
{{Out}}
Line 1,550:
2043</pre>
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
lastyear = 2099;
years = Range[firstyear, lastyear];
Line 1,558:
If[firstday[[n]] == Thursday || lastday[[n]] == Thursday,
Style[years[[n]] " long year \n", Bold, Red] ,
years[[n]] " short \n"], "error \n"], {n, Length[years]}]</
{{out}}
<pre style="height:35ex">{2000 short
Line 1,663:
=={{header|Modula-2}}==
<
FROM InOut IMPORT WriteCard, WriteLn;
Line 1,684:
END;
END;
END LongYear.</
{{out}}
<pre>2004
Line 1,706:
=={{header|Nim}}==
<
proc has53weeks(year: Positive): bool =
Line 1,716:
for year in 2000..2100:
if year.has53weeks:
echo year</
{{out}}
Line 1,740:
=={{header|МК-61/52}}==
<
/ [x] - ИП0 4 ВП 2 / [x] +
^ ^ 7 / [x] 7 * - П1 4
- x#0 40 ИП1 3 - x#0 40 0 С/П
1 С/П</
{{out}}
<pre>
Line 1,750:
</pre>
=={{header|Pascal}}==
<
var
y: integer;
Line 1,784:
if long_year(y) then
writeln(y)
end.</
{{Out}}
<pre>1993
Line 1,799:
==={{header|Free Pascal}}===
Using DateUtils and WeeksInYear to not reinvent this.
<
program Long_year;
Line 1,832:
Readln;
{$ENDIF}
end.</
{{out}}
<pre>
Line 1,845:
=={{header|Perl}}==
<
use warnings;
use DateTime;
Line 1,854:
}
print "\n";
}</
{{out}}
<pre>1903 1908 1914 1920 1925 1931 1936 1942 1948 1953 1959 1964 1970 1976 1981 1987 1992 1998
Line 1,861:
=={{header|Phix}}==
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">week_number</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #000000;">d</span><span style="color: #0000FF;">)</span>
Line 1,880:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Long years in the %d%s century:%v\n"</span><span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">c</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">ord</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">),</span><span style="color: #000000;">long_years</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</
{{out}}
<pre>
Line 1,889:
=={{header|PHP}}==
<
return (53 == strftime('%V', gmmktime(0,0,0,12,28,$year)));
}
Line 1,897:
printf("%s\n", $y);
}
}</
{{Out}}
<pre>1998
Line 1,910:
=={{header|PowerShell}}==
<
param([Int]$year)
53 -eq (Get-Date -Year $year -Month 12 -Day 28 -UFormat %V)
Line 1,919:
Write-Host $y
}
}</
{{Out}}
Line 1,935:
{{trans|C++}}
{{works with|SWI Prolog}}
<
p(Year, P):-
Line 1,972:
main:-
print_long_years(1800, 2100).</
{{out}}
Line 1,987:
=={{header|Python}}==
{{Works with|Python|3.7}}
<
from datetime import date
Line 2,011:
# MAIN ---
if __name__ == '__main__':
main()</
{{Out}}
<pre>2004
Line 2,036:
<code>dayofweek</code> is defined at [[Day of the week#Quackery]]
<
[ 1 1 rot dayofweek 4 = ]
31 12 rot dayofweek 4 = or ] is longyear ( n --> b )
Line 2,044:
100 times
[ 2000 i^ + longyear if
[ 2000 i^ + echo sp ] ]</
{{out}}
Line 2,057:
{{works with|Rakudo|2019.11}}
December 28 is always in the last week of the year. (By ISO8601)
<syntaxhighlight lang="raku"
# Testing
say "Long years in the 20th century:\n", (1900..^2000).grep: &is-long;
say "\nLong years in the 21st century:\n", (2000..^2100).grep: &is-long;
say "\nLong years in the 22nd century:\n", (2100..^2200).grep: &is-long;</
{{out}}
<pre>Long years in the 20th century:
Line 2,074:
=={{header|REXX}}==
<
parse arg LO HI . /*obtain optional args. */
if LO=='' | LO=="," | LO=='*' then LO= left( date('S'), 4) /*Not given? Use default.*/
Line 2,086:
/*──────────────────────────────────────────────────────────────────────────────────────*/
pWeek: parse arg #; return (# + # % 4 - # % 100 + # % 400) // 7
weeks: parse arg y; if pWeek(y)==4 | pWeek(y-1)==3 then return 53; return 52</
{{out|output|text= when using the inputs of: <tt> 1990 2030 </tt>}}
Line 2,135:
=={{header|Ring}}==
<
see "long years 2000-2099: "
for year = 2000 to 2100
Line 2,145:
ok
next
</syntaxhighlight>
{{out}}
<pre>
Line 2,152:
=={{header|Ruby}}==
<
require 'date'
Line 2,160:
(2020..2030).each{|year| puts "#{year} is long? #{ long_year?(year) }." }
</syntaxhighlight>
{{out}}
<pre>2020 is long? true.
Line 2,177:
=={{header|Rust}}==
<
use time::Date;
Line 2,190:
Date::try_from_ymd(year, 12, 28).map_or(false, |date| date.week() == 53)
}
</syntaxhighlight>
{{out}}
<pre>
Line 2,216:
{{Out}}Best seen running in your browser by [https://scastie.scala-lang.org/LDKMJ29SSrehyVbCmiMH1Q Scastie (remote JVM)].
<
import java.time.temporal.{ChronoField, IsoFields}
import java.time.{DayOfWeek, LocalDate, Month}
Line 2,262:
results.zipWithIndex.foreach(solution => println(s"Solution ${solution._2}: ${solution._1.mkString(" ")}"))
}</
=={{header|Scheme}}==
Line 2,271:
The demo code uses <tt>iota</tt> as defined in SRFI-1, so won't work in Schemes lacking that function. Racket requires the addition of <tt>(require srfi/1)</tt>.
<
(remainder (apply + (map (lambda (d) (quotient year d)) '(1 4 -100 400))) 7))
Line 2,277:
(display "Long years between 1800 and 2100:") (newline)
(display (filter long? (iota 300 1800)))</
{{Out}}
Line 2,284:
=={{header|Sidef}}==
<
Date.parse("#{year}-12-28", "%Y-%m-%d").week == 53
}
Line 2,290:
say ( "Long years in the 20th century:\n", (1900..^2000).grep(is_long_year))
say ("\nLong years in the 21st century:\n", (2000..^2100).grep(is_long_year))
say ("\nLong years in the 22nd century:\n", (2100..^2200).grep(is_long_year))</
{{out}}
<pre>
Line 2,304:
=={{header|Snobol}}==
<
DEC31WD DEC31WD = REMDR(Year + (Year / 4) - (Year / 100) + (Year / 400), 7) :(RETURN)
END_DEC31WD
Line 2,322:
ISODEMO(1995, 2045)
END</
{{Out}}
Line 2,337:
=={{header|Swift}}==
<
let year1 = year - 1
let p = (year + (year / 4) - (year / 100) + (year / 400)) % 7
Line 2,347:
for range in [1900...1999, 2000...2099, 2100...2199] {
print("\(range): \(range.filter(isLongYear))")
}</
{{out}}
Line 2,358:
{{trans|C++}}
<syntaxhighlight lang="tcl">
## Reference: https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year
Line 2,383:
puts "Long years between 1800 and 2100:"
print_long_years 1800 2100
puts ""</
{{out}}
<pre>
Line 2,399:
Contents of main module:
<
source = "./iso-long-years"
start_year = 1995
Line 2,407:
output "long-years" {
value = module.iso-long-years.long-years
}</
Contents of <tt>iso-long-years</tt> module:
<
type = number
}
Line 2,432:
value = compact([for y in [for n in local.year_list: tostring(n)]:
module.iso-long-year[y].isLong ? y : ""])
}</
Contents of <tt>iso-long-year</tt> module:
<
type = string
default = ""
Line 2,451:
output isLong {
value = (local.dec31 % 7 == 4 || local.jan1 % 7 == 4)
}</
{{Out}}
Line 2,471:
]</pre>
=={{header|TypeScript}}==
<
const jan1: Date = new Date(year, 0, 1);
const dec31: Date = new Date(year, 11, 31);
Line 2,481:
console.log(y)
}
}</
{{Out}}
Line 2,497:
=== Thursdays check using cal(1) and grep(1) ===
<
cal 1 $1 | grep -q ' 3 *$' && return 0
cal 12 $1 | grep -q ' 26 *$'
}</
=== Straightforward check using GNU date(1) ===
December 28th is always in the last week of the year, so just check whether or not that's week 53:
<
expr $(date -d "$1-12-28" +%V) = 53 >/dev/null
}</
=== Direct computation with built-in arithmetic in newer shells ===
Line 2,513:
{{works with|Korn Shell}}
{{works with|Zsh}}
<
# return weekday (time_t tm_wday, 0=Sunday) of December 31st of the given year
typeset -i y=$1
Line 2,524:
typeset -i y=$1
(( 4 == $(dec31wd $y) || 3 == $(dec31wd $(( y - 1 ))) ))
}</
Demo code for any of the above:
<
if long_year $y; then
echo $y
fi
done | column
</syntaxhighlight>
{{Out}}
Line 2,544:
{{works with|VBA|6.5}}
{{works with|VBA|7.1}}
<
Function IsLongYear(ByVal Year As Integer) As Boolean
Line 2,566:
Next l
End Sub
</syntaxhighlight>
==={{header|Visual Basic for DOS}}===
Translated from Delohi
<
DECLARE FUNCTION p (Yr AS INTEGER) AS INTEGER
Line 2,601:
LongYear = (p(Yr) = 4) OR (p(Yr - 1) = 3)
END FUNCTION
</syntaxhighlight>
=={{header|Wren}}==
{{trans|Go}}
{{libheader|Wren-date}}
<
var centuries = ["20th", "21st", "22nd"]
Line 2,620:
}
System.print(longYears)
}</
{{out}}
Line 2,637:
{{trans|Commodore BASIC}}
{{works with|EXPL-32}}
<
\Long year
code Rem=2, CrLf=9, IntIn=10, IntOut=11, Text=12, Clear=40;
Line 2,662:
CrLf(0);
end
</syntaxhighlight>
{{out}}
<pre>
Line 2,673:
=={{header|zkl}}==
<
foreach nm,y in (T(T("20th",1900), T("21st",2000), T("22nd",2100))){
println("\nLong years in the %s century:\n%s".fmt(nm,
[y..y+99].filter(isLongYear).concat(" ")));
}</
{{out}}
<pre>
|