Javascript下判断是否为闰年的Datetime包


Posted in Javascript onOctober 26, 2010

来看看源码:

/** 
* jscript.datetime package 
* This package contains utility functions for working with dates and times. 
*/ 
/*命名空间*/ 
if (typeof jscript == 'undefined') { 
jscript = function() { } 
} jscript.datetime = function() { } 
/** 
* This function will return the number of days in a given month and year, 
* taking leap years into account.(这个函数返回所给某年、某月的天数,并且考虑了闰年的情况) 
* 
* @param inMonth The month, where January = 1 and December = 12. 
* @param inYear The year to check the month in. 
* @return The number of days in the specified month and year. 
*/ 
jscript.datetime.getNumberDaysInMonth = function(inMonth, inYear) { 
inMonth = inMonth - 1; 
var leap_year = this.isLeapYear(inYear); 
if (leap_year) { 
leap_year = 1; 
} else { 
leap_year = 0; 
} 
/*4, 6, 9, 11 月为 30 天,注意上面的 inMonth = inMonth - 1*/ 
if (inMonth == 3 || inMonth == 5 || inMonth == 8 || inMonth == 10) { 
return 30; 
} else if (inMonth == 1) {/*2 月为 28 或者 29 天,视是否为闰年而定*/ 
return 28 + leap_year; 
} else {/*其它月则为 31 天*/ 
return 31; 
} 
} // End getNumberDaysInMonth(). 

/** 
* This function will determine if a given year is a leap year. 
*(这个函数用来确定是否为闰年) 
* @param inYear The year to check. 
* @return True if inYear is a leap year, false if not. 
*/ 
jscript.datetime.isLeapYear = function(inYear) { 
if ((inYear % 4 == 0 && !(inYear % 100 == 0)) || inYear % 400 == 0) { 
return true; 
} else { 
return false; 
} 
} // End isLeapYear().
Javascript 相关文章推荐
jQuery学习4 浏览器的事件模型
Feb 07 Javascript
分享一个我自己写的ToolTip提示插件(附源码)
Jan 20 Javascript
Extjs NumberField后面加单位实现思路
Jul 30 Javascript
学习javascript面向对象 实例讲解面向对象选项卡
Jan 04 Javascript
JavaScript中定义类的方式详解
Jan 07 Javascript
使用JS在浏览器中判断当前网络连接状态的几种方法
May 05 Javascript
js canvas实现QQ拨打电话特效
May 10 Javascript
详解angularJS动态生成的页面中ng-click无效解决办法
Jun 19 Javascript
如何理解Vue的render函数的具体用法
Aug 30 Javascript
在vue中使用Autoprefixed的方法
Jul 27 Javascript
vue tab切换,解决echartst图表宽度只有100px的问题
Jul 19 Javascript
微信小程序实现点击生成随机验证码
Sep 09 Javascript
基于jquery的给文章加入关键字链接
Oct 26 #Javascript
EasyUi tabs的高度与宽度根据IE窗口的变化自适应代码
Oct 26 #Javascript
自写的一个jQuery圆角插件
Oct 26 #Javascript
jQuery获取地址栏参数插件(模仿C#)
Oct 26 #Javascript
自制轻量级仿jQuery.boxy对话框插件代码
Oct 26 #Javascript
jquery ui resizable bug解决方法
Oct 26 #Javascript
HTML Dom与Css控制方法
Oct 25 #Javascript
You might like
php5.5中类级别的常量使用介绍
2013/10/02 PHP
Yii框架在页面输出执行sql语句以方便调试的实现方法
2014/12/24 PHP
yii数据库的查询方法
2015/12/28 PHP
对比分析php中Cookie与Session的异同
2016/02/19 PHP
CI框架AR操作(数组形式)实现插入多条sql数据的方法
2016/05/18 PHP
ThinkPHP框架获取最后一次执行SQL语句及变量调试简单操作示例
2018/06/13 PHP
jquery nth-child()选择器的简单应用
2010/07/10 Javascript
Extjs中DisplayField的日期或者数字格式化扩展
2010/09/03 Javascript
基于jquery可配置循环左右滚动例子
2011/09/09 Javascript
Javascript中拼接大量字符串的方法
2015/02/05 Javascript
javascript正则表达式中的replace方法详解
2015/04/20 Javascript
JavaScript代码判断点击第几个按钮
2015/12/13 Javascript
javascript中json基础知识详解
2017/01/19 Javascript
vue.js移动端app之上拉加载以及下拉刷新实战
2017/09/11 Javascript
详解Vue 事件修饰符capture 的使用
2017/12/29 Javascript
详解关于html,css,js三者的加载顺序问题
2019/04/10 Javascript
ant-design-vue 快速避坑指南(推荐)
2020/01/21 Javascript
使用Webpack 搭建 Vue3 开发环境过程详解
2020/07/28 Javascript
[04:29]2014DOTA2国际邀请赛 主赛事第三日TOPPLAY
2014/07/21 DOTA
python模块restful使用方法实例
2013/12/10 Python
Python算法输出1-9数组形成的结果为100的所有运算式
2017/11/03 Python
基于Python实现定时自动给微信好友发送天气预报
2018/10/25 Python
Pyqt5实现英文学习词典
2019/06/24 Python
Python批量将图片灰度化的实现代码
2020/04/11 Python
Python如何利用Har文件进行遍历指定字典替换提交的数据详解
2020/11/05 Python
python matplotlib工具栏源码探析三之添加、删除自定义工具项的案例详解
2021/02/25 Python
canvas小画板之平滑曲线的实现
2020/08/12 HTML / CSS
Bravofly德国:预订廉价航班和酒店
2019/09/22 全球购物
触发器(trigger)的功能都有哪些?写出一个触发器的例子
2012/09/17 面试题
毕业生找工作的自我评价
2013/10/18 职场文书
英语专业应届生求职信范文
2013/11/15 职场文书
网络管理员岗位职责
2014/03/17 职场文书
小学优秀班干部事迹材料
2014/05/25 职场文书
大专生求职信
2014/06/29 职场文书
信访工作个人总结
2015/03/03 职场文书
win11无线投屏在哪设置? win11无线投屏功能的使用方法
2022/04/08 数码科技