Today   (2020-02-02,   at the time of this writing)   happens to be a palindrome,   without the hyphens,   not only for those countries which express their dates in the   yyyy-mm-dd   format but,   unusually,   also for countries which use the   dd-mm-yyyy   format.



Task
Write a program which calculates and shows the next 15 palindromic dates for those countries which express their dates in the   yyyy-mm-dd   format.




NewList pdates.s()
 
Procedure.b IsLeap(y.i)
  ProcedureReturn Bool( y % 4 = 0 ) & Bool( y % 100 <> 0 ) | Bool( y % 400 = 0 )
EndProcedure
 
If OpenConsole("")=0 : End 1 : EndIf
 
For j=2021 To 9999
  For m=1 To 12
    tm2=28+1*IsLeap(j)
    For t=1 To 31
      If m=2 And t>tm2 : Break : EndIf      
      If (m=4 Or m=6 Or m=9 Or m=11) And t>30 : Break : EndIf      
      s$=Str(j)+RSet(Str(m),2,"0")+RSet(Str(t),2,"0")
      If ReverseString(s$)=s$
        AddElement(pdates()) : pdates()=Mid(s$,1,4)+"-"+Mid(s$,5,2)+"-"+Mid(s$,7,2)
      EndIf
    Next t
  Next m
Next j
 
PrintN("Count of palindromic dates [2021..9999]: "+Str(ListSize(pdates())))
FirstElement(pdates())
t$="First 15:"
For x=1 To 2  
  PrintN(~"\n"+t$)
  For y=1 To 15 : PrintN(pdates()) : NextElement(pdates()) : Next  
  t$="Last 15:" : SelectElement(pdates(),ListSize(pdates())-15)
Next
Input() : End