{"id":2431,"date":"2017-04-01T00:01:16","date_gmt":"2017-04-01T07:01:16","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=2431"},"modified":"2017-04-08T08:21:18","modified_gmt":"2017-04-08T15:21:18","slug":"calculating-the-date-of-easter","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=2431","title":{"rendered":"Calculating the Date of Easter"},"content":{"rendered":"<p>Of all the annual holidays, Easter is the most difficult date to predict. It&#8217;s always a Sunday, but which one? It could land in March or April. Most people look at a calendar or (these days) use Google to find out when Easter occurs. Yet, you can write a program that tells you exactly when Easter falls.<br \/>\n<!--more--><br \/>\nThe reason behind Easter&#8217;s changing date is that it&#8217;s based on a lunar calendar, not the standard solar calendar in common use. Easter occurs on the first Sunday after the first full moon after the vernal equinox.<\/p>\n<p>The vernal (spring) equinox is always around March 20th or 21st. That&#8217;s because the solar calendar we use is pretty accurate. Indeed, having such a predictable date for the equinox is why the Julian and then Gregorian calendar reforms occurred.<\/p>\n<p>The first full moon after the vernal equinox marks the Jewish passover. It can occur right after March 20\/21 or it could be up to 28 days later, in April. Easter is then celebrated on the following Sunday.<\/p>\n<p>To calculate the date upon which Easter falls, you must know the date of the equinox and the lunar full-moon cycle as well as the day of the week upon which the full moon falls. To gather those variables, you use a formula. This formula is so famous, it has its own name: the <em>computus<\/em>.<\/p>\n<p>In Figure 1, you see pseudocode presented. It&#8217;s what&#8217;s known as the Anonymous Gregorian algorithm, which first appeared in the journal <em>Nature<\/em> in 1876.<\/p>\n<div id=\"attachment_2434\" style=\"width: 344px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2434\" src=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2017\/04\/0401-Exercise_fig1.png\" alt=\"\" width=\"334\" height=\"433\" class=\"size-full wp-image-2434\" srcset=\"https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2017\/04\/0401-Exercise_fig1.png 334w, https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2017\/04\/0401-Exercise_fig1-231x300.png 231w\" sizes=\"auto, (max-width: 334px) 100vw, 334px\" \/><p id=\"caption-attachment-2434\" class=\"wp-caption-text\">Figure 1. The Anonymous Gregorian <em>computus<\/em> algorithm.<\/p><\/div>\n<p>The algorithm works top-down: Variables are <code>a<\/code> through <code>m<\/code> (I wrote <code>l<\/code> in uppercase, <code>L<\/code>, to be clear); <code>Y<\/code> is the year value; <code>mod<\/code> is the modulus operation; <code>floor<\/code> is a mathematical function that rounds down to the next integer. At the end of the operation, values <code>month<\/code> and <code>day<\/code> indicate the month (3 for March, 4 for April) and day on which Easter falls for year <code>Y<\/code>.<\/p>\n<p>Your task for this month&#8217;s Exercise is to use the Anonymous Gregorian <em>computus<\/em> algorithm to calculate the dates upon which Easter falls. You must write two programs: The first displays Easter&#8217;s day for years 2001 through 2021. The second program displays the date of Easter for the current year only.<\/p>\n<p>I&#8217;ll present <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=2446\">my solution<\/a> in a week.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Formulas, or algorithms, exist to perform many tasks. Your job is to translate them into C code. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=2431\">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-2431","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\/2431","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=2431"}],"version-history":[{"count":6,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2431\/revisions"}],"predecessor-version":[{"id":2467,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2431\/revisions\/2467"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}