<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 問題 Problem 你需要計算出某年復活節所在地月份和日期。 You need to find the month and day of the Easter Sunday for given year. ## 方案 Solution 下面這個函數返回一個數組,包含兩個元素:復活節的月份(1-12)和日期。如果省略參數,給出的就是當年的結果。這是[Anonymous Gregorian algorithm](http://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm)CoffeeScript實現。 The following function returns array with two elements: month (1-12) and day of the Easter Sunday. If no arguments are given result is for the current year. This is an implementation of?[Anonymous Gregorian algorithm](http://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm)?in CoffeeScript. ~~~ gregorianEaster = (year = (new Date).getFullYear()) -> a = year % 19 b = ~~(year / 100) c = year % 100 d = ~~(b / 4) e = b % 4 f = ~~((b + 8) / 25) g = ~~((b - f + 1) / 3) h = (19 * a + b - d - g + 15) % 30 i = ~~(c / 4) k = c % 4 l = (32 + 2 * e + 2 * i - h - k) % 7 m = ~~((a + 11 * h + 22 * l) / 451) n = h + l - 7 * m + 114 month = ~~(n / 31) day = (n % 31) + 1 [month, day] ~~~ ## 討論 Discussion 注意!JavaScript把月份記作從0到11,因此如果調用`.getMonth()`,日期在三月份,則返回值為2,但是上面這個函數返回的是3。如果你想保持一致,你可以修改這個函數。 NB! Javascript numbers months from 0 to 11 so?`.getMonth()`?for date in March will return 2, this function will return 3\. You can modify the function if you want this to be consistent. 這個函數還是用了`~~`技巧來代替`Math.floor()`。 The function uses ~~ trick instead of Math.floor(). ~~~ gregorianEaster() # => [4, 24] (April 24th in 2011) gregorianEaster 1972 # => [4, 2] ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看