Palindrome dates: Difference between revisions
Content added Content deleted
(New post with C++20 syntax and without external libraries. In addition to an existing post which uses the "Boost" library.) |
imported>Nmz (Added Lua section {{header|lua}}) |
||
Line 1,647: | Line 1,647: | ||
2190-09-12 |
2190-09-12 |
||
</pre> |
</pre> |
||
=={{header|Lua}}== |
|||
<syntaxhighlight lang="lua"> |
|||
local year = 2020 |
|||
for i=1, 15 do |
|||
local dateS |
|||
repeat |
|||
year = year+1 |
|||
local yearS = tostring(year) |
|||
local monthS, dayS = yearS:reverse():match"^(%d%d)(%d%d)$" |
|||
local monthN, dayN = tonumber(monthS), tonumber(dayS) |
|||
dateS = yearS .. "-" .. monthS .. "-" .. dayS |
|||
until |
|||
monthN>0 and monthN<=12 -- real month |
|||
and dayN>0 and dayN<32 -- possible day |
|||
and os.date( -- real date check |
|||
"%Y-%m-%d" |
|||
,os.time{ |
|||
year = year |
|||
,month = monthN |
|||
,day = dayN |
|||
} |
|||
) == dateS |
|||
print(dateS) |
|||
end |
|||
</syntaxhighlight> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |