0

i needed some help in figuring out how to work out the Leap year for the next and previous years if the entered date is not a leap year.

for e.g. = 1993 is not a leap year, the next leap year is 1996 and the previous leap year is 1992.

        <form>
            <input type="text" name="year">
            <input type="submit" name="Leap Year?">
        </form>

        {*Variables*}
        {$ca.LeapYearYes = {$ca.year%400==0||(($ca.year%4==0)&&($ca.year%100!=0))}}
        {$ca.NextLeapYear = {$ca.year + 4}}
        {$ca.PreviousLeapYear = {$ca.year - 4}}
        {$ca.LeapYearNo1 = {$ca.year + 1}}


        {if $ca.LeapYearYes}
            This is a Leap Year!</br>
            The Next Leap Year is {$ca.NextLeapYear} </br>
            The Previous Leap Year was {$ca.PreviousLeapYear} </br>
        {else}
            {$ca.LeapYearYes = false}
            {$ca.year} is not a Leap Year</br>
            The Next Leap Year is 
            {if $ca.LeapYearYes = false}
                {$ca.LeapYearNo1}
            {elseif $ca.year = true}
                {$ca.LeapYearYes}
            {/if}
            {$ca.year}
        {/if}       
    </div>```
Wonderer
  • 3
  • 1
  • jQuery is a framework primarily used for working with the DOM. This is why your research may not have found your answer. When working with dates, or any other primitive type you should use JS directly - as per the answer in the duplicate I marked. – Rory McCrossan Feb 12 '21 at 10:59
  • @RoryMcCrossan - thank you. i need help with the calculation on how to get the next and previous dates. the post you have linked doesnt have the answer – Wonderer Feb 12 '21 at 11:07
  • Get the previous and next 4 years. Loop through them calling the function which returns if that year is a leap year, based on the code in the question I lined to – Rory McCrossan Feb 12 '21 at 11:21

0 Answers0