Jquery时间快捷控件(Jtime)配置v1.1
1、插件代码
/**
* @title 时间工具类
* @note 本类一律违规验证返回false
* @author {boonyachengdu@gmail.com}
* @date 2013-07-01
* @formatter "2013-07-01 00:00:00" , "2013-07-01", "2013-07-01 23:59:59"
* @version LBS2.0
* @param plugin Jtime v1.1
* @notice 兼容性 支持 chrome 、firefox、IE8 (其他浏览器未测试过)
*/
(function(){
window.TimeObjectUtil={};
TimeObjectUtil = {
/**
* 获取当前时间毫秒数
*/
getCurrentMsTime : function() {
var myDate = new Date();
return myDate.getTime();
},
/**
* 毫秒转时间格式
*/
longMsTimeConvertToDateTime : function(time) {
var myDate = new Date(time);
return this.formatterDateTime(myDate);
},
/**
* 时间格式转毫秒
*/
dateToLongMsTime : function(date) {
var myDate = new Date(date);
return myDate.getTime();
},
/**
* 格式化日期(不含时间)
*/
formatterDate : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate());
return datetime;
},
/**
* 格式化日期(含时间"00:00:00")
*/
formatterDateZeroTime : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate()) + " " + "00:00:00";
return datetime;
},
/**
* 格式化去日期(含时间)
*/
formatterDateTime : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate())
+ " "
+ (date.getHours() < 10 ? "0" + date.getHours() : date
.getHours())
+ ":"
+ (date.getMinutes() < 10 ? "0" + date.getMinutes() : date
.getMinutes())
+ ":"
+ (date.getSeconds() < 10 ? "0" + date.getSeconds() : date
.getSeconds());
return datetime;
},
/**
* 时间比较{结束时间大于开始时间}
*/
compareDateEndTimeGTStartTime : function(startTime, endTime) {
return ((new Date(endTime.replace(/-/g, "/"))) > (new Date(
startTime.replace(/-/g, "/"))));
},
/**
* 验证开始时间合理性{开始时间不能小于当前时间{X}个月}
*/
compareRightStartTime : function(month, startTime) {
var now = this.formatterDateTime(new Date());
var sms = new Date(startTime.replace(/-/g, "/"));
var ems = new Date(now.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = ems - sms;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 验证开始时间合理性{结束时间不能小于当前时间{X}个月}
*/
compareRightEndTime : function(month, endTime) {
var now = this.formatterDateTime(new Date());
var sms = new Date(now.replace(/-/g, "/"));
var ems = new Date(endTime.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = sms - ems;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 验证开始时间合理性{结束时间与开始时间的间隔不能大于{X}个月}
*/
compareEndTimeGTStartTime : function(month, startTime, endTime) {
var sms = new Date(startTime.replace(/-/g, "/"));
var ems = new Date(endTime.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = ems - sms;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 获取最近几天[开始时间和结束时间值,时间往前推算]
*/
getRecentDaysDateTime : function(day) {
var sday=new Date();
sday.setDate(sday.getDate()-day);
sday.setHours(0, 0, 0, 0);
sday=this.formatterDateTime(sday);
var eday=new Date();
if(day!=0) eday.setDate(eday.getDate()-1);
eday.setHours(23, 59, 59, 59);
eday=this.formatterDateTime(eday);
var obj = {
startTime : sday,
endTime : eday
};
return obj;
},
/**
* 获取今天[开始时间和结束时间值]
*/
getTodayDateTime : function() {
var stoday=new Date();
stoday.setHours(0, 0, 0, 0);
stoday=this.formatterDateTime(stoday);
var etoday=new Date();
etoday.setHours(23, 59, 59, 59);
etoday=this.formatterDateTime(etoday);
var obj = {
startTime : stoday,
endTime : etoday
};
return obj;
},
/**
* 获取明天[开始时间和结束时间值]
*/
getTomorrowDateTime : function() {
var stomorrow=new Date();
stomorrow.setDate(stomorrow.getDate()+1);
stomorrow.setHours(0, 0, 0, 0);
stomorrow=this.formatterDateTime(stomorrow);
var etomorrow=new Date();
etomorrow.setDate(etomorrow.getDate()+1);
etomorrow.setHours(23, 59, 59, 59);
etomorrow=this.formatterDateTime(etomorrow);
var obj = {
startTime : stomorrow,
endTime : etomorrow
};
return obj;
}
};
})();
2、使用配置
/*-----------------------------------------使用配置方式------------------------------------------*/
//执行策略
function executeTimeCase(key){
return TimeObjectUtil.getRecentDaysDateTime(key); //今天0,明天-1,昨天1,前天2,近三天3,近七天7,近n天n,未来n天-n
}
Jquery时间快捷控件(Jtime)配置v1.1的更多相关文章
- Jquery时间快捷控件(Jtime)配置v1.0
1.脚本代码行 /** * @title 时间工具类 * @note 本类一律违规验证返回false * @author {boonyachengdu@gmail.com} * @date 2013- ...
- ExtJs控件属性配置详细
序言: 1.本文摘自网络,看控件命名像是4.0以前的版本,但控件属性配置仍然可以借鉴(不足之处,以后项目用到时再续完善). Ext.form.TimeField: 配置项: ...
- 基于jQuery 常用WEB控件收集
Horizontal accordion: jQuery 基于jQuery开发,非常简单的水平方向折叠控件. Horizontal accordion: jQuery jQuery-Horizonta ...
- 43. ExtJs控件属性配置详细
转自:https://www.cnblogs.com/mannixiang/p/6558225.html 序言: 1.本文摘自网络,看控件命名像是4.0以前的版本,但控件属性配置仍然可以借鉴(不 ...
- jquery插件——日历控件
今天在网上有看到一个jquery插件——日历控件,不过之前也在柯乐义的网站上看到了(http://keleyi.com/ 推荐下) 这个插件看着比较大气,所以干脆也分享下,以后自己也好用一点儿 1.页 ...
- 弹出框页面中使用jquery.validate验证控件
弹出框页面中使用jquery.validate验证控件有几个问题需要解决: 1,弹出框的提交事件完成后如何关闭弹出框页面? 2,提交不成功如何返回当前页? 3,如果知道验证事件成功? 之前笔者都是JS ...
- SNF开发平台WinForm之十五-时间轴控件使用-SNF快速开发平台3.3-Spring.Net.Framework
一.显示效果如下: 二.在控件库里选择UCTimeAxis 拖拽到窗体里. 三.加入以下代码,在load事件里进行调用就可以运行了. #region 给时间轴控件加载数据 private void U ...
- 给easyui datebox时间框控件扩展一个清空的实例
给easyui datebox扩展一个清空的实例 步骤一:拓展插件 /** * 给时间框控件扩展一个清除的按钮 */ $.fn.datebox.defaults.cleanText = '清空'; ( ...
- 一些基于jQuery开发的控件
基于jQuery开发,非常简单的水平方向折叠控件.主页:http://letmehaveblog.blogspot.com/2007/10/haccordion-simple-horizontal-a ...
随机推荐
- 【转】android 兼容性测试 CTS 测试过程(实践测试验证通过)
原文网址:http://blog.csdn.net/jianguo_liao19840726/article/details/7222814 写这个博客的时候是为了记忆,建议大家还是看官方的说明,官方 ...
- 【转】notepad++设置字体和字体大小
原文网址:http://www.aichengxu.com/view/604 今天很多朋友问我怎么设置notepad++的代码字体和代码字体的大小,习惯了editplus的朋友可能会在notepad+ ...
- linux之getcwd函数解析
[lingyun@localhost getcwd]$ cat getcwd.c /********************************************************** ...
- 对每个用户说hello
#!/bin/bash #对每个用户说hello #用户数 Lines=`wc -l /etc/passwd | cut -d' ' -f1` $Lines`; do echo "Hello ...
- hdu 4007 Dave(线性探查+枚举)
Problem Description Recently, Dave is boring, so he often walks around. He finds that some places ar ...
- 面试时如何优雅的谈论OC
在面试中,我们经常会遇到一些原理性的问题,很常识但很难用通俗的语言解释清楚,这也是大部分业务级程序员经常失误的地方.虽然写了多年代码,但是核心思想不清,导致自己的后续发展受限,这是一个优秀的程序员和普 ...
- Android应用程序资源的查找过程分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8806798 我们知道,在Android系统中, ...
- Git 版本回退问题详解
版本回退 git log , git reset --hard xxxx回退到以前的版本 git reflog, git reset --hard xxx 回退到将来的版本 现在,你已经学会 ...
- [core java学习笔记][第十章部署应用程序]
第10章 部署应用程序和applet jar文件 Java Web Start 10.1 jar文件 jar文件就是一个压缩了类,图像和声音的ZIP压缩文件 创建一个新的JAR文件应该使用的常见命令格 ...
- js判断是否是数字通用写法
function isNumber(value){ var isNumber = value.match(/^(-?\d+)(\.\d+)?$/g) !=null; if(value.substrin ...