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 相关文章推荐
javascript event 事件解析
Jan 31 Javascript
window.location.href IE下跳转失效的解决方法
Mar 27 Javascript
网页中表单按回车就自动提交的问题的解决方案
Nov 03 Javascript
JavaScript 实现的 zip 压缩和解压缩工具包Zip.js使用详解
Dec 14 Javascript
拥有一个属于自己的javascript表单验证插件
Mar 24 Javascript
iscroll碰到Select无法选择下拉刷新的解决办法
May 21 Javascript
JQuery在循环中绑定事件的问题详解
Jun 02 Javascript
javascript 常用验证函数总结
Jun 28 Javascript
AngularJS框架中的双向数据绑定机制详解【减少需要重复的开发代码量】
Jan 19 Javascript
JS中使用react-tooltip插件实现鼠标悬浮显示框
May 15 Javascript
详解Nuxt内导航栏的两种实现方式
Apr 16 Javascript
React 高阶组件HOC用法归纳
Jun 13 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
php数组函数array_key_exists()小结
2015/12/10 PHP
[原创]php token使用与验证示例【测试可用】
2017/08/30 PHP
js 页面刷新location.reload和location.replace的区别小结
2009/12/24 Javascript
jQuery 拖动层(在可视区域范围内)
2012/05/24 Javascript
页面定时刷新(1秒刷新一次)
2013/11/22 Javascript
location.href用法总结(最主要的)
2013/12/27 Javascript
jquery的ajax和getJson跨域获取json数据的实现方法
2014/02/04 Javascript
JavaScript将取代AppleScript?
2014/09/18 Javascript
JavaScript中的Function函数
2015/08/27 Javascript
JQuery Mobile 弹出式登录框的实现方法
2016/05/28 Javascript
JS Canvas定时器模拟动态加载动画
2016/09/17 Javascript
Bootstrap表格使用方法详解
2017/02/17 Javascript
整理关于Bootstrap排版的慕课笔记
2017/03/29 Javascript
重新认识vue之事件阻止冒泡的实现
2018/08/02 Javascript
vue-cli 2.*中导入公共less文件的方法步骤
2018/11/22 Javascript
echarts多条折线图动态分层的实现方法
2019/05/24 Javascript
vue实现的上拉加载更多数据/分页功能示例
2019/05/25 Javascript
小程序按钮避免多次调用接口和点击方案实现(不用showLoading)
2020/04/15 Javascript
解决vuex改变了state的值,但是页面没有更新的问题
2020/11/12 Javascript
浅谈Python的文件类型
2016/05/30 Python
python3 tcp的粘包现象和解决办法解析
2019/12/09 Python
使用python tkinter开发一个爬取B站直播弹幕工具的实现代码
2021/02/07 Python
基于html5绘制圆形多角图案
2016/04/21 HTML / CSS
KENZO官网:高田贤三在法国创立的品牌
2019/05/16 全球购物
家乐福台湾线上购物网:Carrefour台湾
2020/09/15 全球购物
个人简历自我评价
2014/01/06 职场文书
护士求职自荐信范文
2014/03/19 职场文书
入职担保书范文
2014/05/21 职场文书
群众路线剖析材料(四风)
2014/11/05 职场文书
团代会邀请函
2015/02/02 职场文书
2019入党申请书范文3篇
2019/08/21 职场文书
PostgreSQL存储过程实用脚本(二):创建函数入门
2021/04/05 PostgreSQL
JDBC连接的六步实例代码(与mysql连接)
2021/05/12 MySQL
用JS实现飞机大战小游戏
2021/06/09 Javascript
阿里云服务器部署mongodb的详细过程
2021/09/04 MongoDB
基于MySql验证的vsftpd虚拟用户
2021/11/07 MySQL