You could test the year in a split or create a boolean variable with:
if(($year mod 400 = 0) or (($year mod 4 = 0) and ($year mod 100 != 0))) then true else false
For an example flow see here
That is a broad question. When building your app this aspect should always be in the back of your mind. A general answer can not be given. A good site about mathematical calculations you can find here: http://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm
Then you can at least do a check if something is a leap year.