To use it:
Push "year"
Call IsLeapYear
Pop $0 ;returns 0 or 1
Push "month"
Push "year"
Call DaysInMonth
Pop $0 ; returns 28, 29, 30 or 31
Function IsLeapYear
Pop $0
IntOp $1 $0 % 4
IntCmp $1 0 test2 ;si divisible par 4, on passe au test 2 (début de siècle)
Goto ko ;sinon, retourne FAUX
test2:
IntOp $1 $0 % 100
IntCmp $1 0 test3
Goto ok
test3:
;l'année est un siècle rond
;on vérifie si ce siècle est impair
IntOp $1 $0 % 200
IntCmp $1 0 ok
Goto ko
ok:
Push 1
Goto end
ko:
Push 0
end:
FunctionEnd
Function DaysInMonth
Pop $0 ;annee
Pop $1 ;mois
IntCmp $1 1 m31
IntCmp $1 2 m28
IntCmp $1 3 m31
IntCmp $1 4 m30
IntCmp $1 5 m31
IntCmp $1 6 m30
IntCmp $1 7 m31
IntCmp $1 8 m31
IntCmp $1 9 m30
IntCmp $1 10 m31
IntCmp $1 11 m30
IntCmp $1 12 m31
m31:
Push 31
Goto end
m30:
Push 30
Goto end
m28:
Push $0
Call IsLeapYear
Pop $0
IntCmp $0 1 m29
Push 28
Goto end
m29:
Push 29
end:
FunctionEnd