title: javascript date serial number
body: <p><strong>NB: I cannot use the function Date</strong></p>
  
  <p>Goal: convert a date, starting from 1st January 1900 to 31st December 2199, in a serial number that varies from 1 to 109573. Returns 0 if the date is invalid. </p>
  
  <p>Examples: </p>
  
  <ol>
  <li>dateSerialNumber( 1, 1,1900) returns 1</li>
  <li>dateSerialNumber(21, 3,2012) returns 40988</li>
  <li>dateSerialNumber(31,12,2199) returns 109573</li>
  <li>dateSerialNumber(31,12,1899) returns 0</li>
  <li>dateSerialNumber(31,13,2000) returns 0</li>
  <li>dateSerialNumber(29, 2,1991) returns 0</li>
  </ol>
  
  <p><strong><em>Some more examples:</em></strong>
  <a href="http://i.stack.imgur.com/9eiHN.png" rel="nofollow"><strong>Examples of serial number by year</strong></a></p>
  
  <p>I should also use functions I've already coded:</p>
  
  <ol>
  <li>dateValid(intDay, intMonth, intYear)</li>
  <li>numberDaysInYear(intYear)</li>
  <li>numberDaysInMonth(intMonth, intYear)</li>
  </ol>
  
  <p>1)
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function dateValid(intDay, intMonth, intYear) {
      if ((intYear &gt;= 1900 &amp;&amp; intYear &lt;= 2199) &amp;&amp; (intMonth &gt;= 1 &amp;&amp; intMonth &lt;= 12)
          &amp;&amp; (intDay &gt;= 1 &amp;&amp; intDay &lt;= numberDaysInMonth(intMonth, intYear))) {
        return true;
      }else return false;
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>2)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function numberDaysInYear(intYear) {
     if(bissextile(intYear)) return '366'
     else return '365'
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>3)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function numberDaysInMonth(intMonth, intYear) {
     return new Date(intYear, intMonth, 0).getDate();
  }</code></pre>
  </div>
  </div>
  </p>