<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ## 問題 Problem 你需要算出給你年份哪一天過感恩節。 You need to calculate when is Thanksgivinig in given year. ## 方案 Solution 下面這個函數將返回給定年份感恩節的日期。如果沒有指定年份,就計算當年的。 The following functions return the day of Thanksgiving for a given year. If no year is given then current year is used. 美國人在每年的11月的第4個星期四慶祝他們自己的感恩節。 In the USA Thanksgiving is celebrated on the fourth Thursday in November: ~~~ thanksgivingDayUSA = (year = (new Date).getFullYear()) -> first = new Date year, 10, 1 day_of_week = first.getDay() 22 + (11 - day_of_week) % 7 ~~~ 而在加拿大,是十月的第2個周一。 In Canada it is the second Monday in October: ~~~ thanksgivingDayCA = (year = (new Date).getFullYear()) -> first = new Date year, 9, 1 day_of_week = first.getDay() 8 + (8 - day_of_week) % 7 ~~~ ## 討論 Discussion ~~~ thanksgivingDayUSA() #=> 24 (November 24th, 2011) thanksgivingDayCA() # => 10 (October 10th, 2011) thanksgivingDayUSA(2012) # => 22 (November 22nd) thanksgivingDayCA(2012) # => 8 (October 8th) ~~~ 思想非常簡單: 1. 找出相應的月份第一天對應的是星期幾(美國是11月,而加拿大是10月); 2. 計算出到下一個要求的星期幾有多少天(美國是周四,加拿大是周一); 3. 再加上距離第一個可能的假期的天數(美國的感恩節是第22天,加拿大的是第8天); The idea is very simple: 1. Find out what day of the week is the first day of respective month (November for USA, October for Canada). 2. Calculate offset from that day to the next occurrence of weekday required (Thursday for USA, Monday for Canada). 3. Add that offset to the first possible date of the holiday (22nd for USA Thanksgiving, 8th for Canada).
                  <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>

                              哎呀哎呀视频在线观看