{"id":3111,"date":"2018-06-01T00:01:45","date_gmt":"2018-06-01T07:01:45","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=3111"},"modified":"2018-06-08T21:52:39","modified_gmt":"2018-06-09T04:52:39","slug":"the-leap-year-function","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=3111","title":{"rendered":"The Leap Year Function"},"content":{"rendered":"<p>My brain&#8217;s algorithm for determining whether the current year is a leap year is based on US Presidential elections. They always happen on a leap year. Or do they?<br \/>\n<!--more--><br \/>\nThe Presidential Election of 2000 was a leap year, but the Presidential Election of 1900 was not. Fortunately, I wasn&#8217;t alive then. Nor will I be alive (most likely) in 2100, which is also a Presidential Election year, but not a leap year.<\/p>\n<p><em>O leap year math!<\/em><\/p>\n<p>Here are the leap year rules:<\/p>\n<ul>\n<li>IF the year is evenly divisible by 4, it is a leap year . . .<\/li>\n<li>UNLESS the year is also evenly divisible by 100, it&#8217;s not a leap year . . .<\/li>\n<li>UNLESS it&#8217;s also divisible by 400, it is a leap year.<\/li>\n<\/ul>\n<p>The year 1900 was evenly divisible by both 4 and 100, but not 400. It wasn&#8217;t a leap year.<\/p>\n<p>The year 2000 was evenly divisible by both 4 and 100, so it shouldn&#8217;t be a leap year, but it&#8217;s also evenly divisible by 400. It was a leap year.<\/p>\n<p>The Gregorian Calendar, introduced in 1582, uses these rules to keep dates aligned with the seasons and it&#8217;s proven to be quite effective since that time.<\/p>\n<p>The first actual leap year under this new calendar occurred in 1584. Your task for this month&#8217;s Exercise is to displays values from that date until the year 2100, skipping every four years and proclaiming whether February in that specific year had a 29th day. Use the leap year rules stated above to craft a function that determines whether a given year is a leap year.<\/p>\n<p>Try this Exercise on your own before you look at <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=3134\">my solution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Gregorian calendar fixed the leap year calculation and Pope Gregory XIII did it without any knowledge of C coding. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3111\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3111","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3111"}],"version-history":[{"count":7,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3111\/revisions"}],"predecessor-version":[{"id":3155,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3111\/revisions\/3155"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}