zoukankan      html  css  js  c++  java
  • javascript獲得當前月的天數

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head>

     <body>
      <script type="text/javascript">
      <!--
     function m_DaysInMonth(pYear,pMonth){
        var nDays = 30;
        if(pMonth==2){    //2月单独处理
            if(m_IsLeap(pYear)) nDays = 29;
            else nDays = 28;
        }
        else if(mInList(pMonth,"1,3,5,7,8,10,12")){
            nDays = 31;   
        }
        return nDays;
    }

    //判断某年是否是闰年
    function m_IsLeap(pYear){
        if(pYear % 400 == 0){
            return true;
        }
        else if((pYear % 100 != 0) && (pYear % 4 == 0)){
            return true;
        }
        return false;
    }

    //判断是否在字符串列表里:
    // if(mInList("3","1,3,5,7,8,10,12")){   //true
    // if(mInList("2","1,3,5,7,8,10,12")){   //false

    function mInList(s1,slist){
       var ss1=","+s1+",";
       var ss2=","+slist+",";
       ss1 = ss1.toLowerCase();
       ss2 = ss2.toLowerCase();
       return ss2.indexOf(ss1)!=-1;
    }
    alert(m_DaysInMonth(2011,2));

      //-->
      </script>
     </body>
    </html>

  • 相关阅读:
    gvim : invalid input string
    端口
    Sequence Overview
    vi的使用
    Ubuntu安装CodeBlocks相关问题总结
    中断
    Ubuntu Software Repository
    UVA 12299 RMQ with Shifts
    UVA 12293 Box Game
    POJ 3468 A Simple Problem with Integers (1)
  • 原文地址:https://www.cnblogs.com/lv_yantao/p/2240551.html
Copyright © 2011-2022 走看看