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的更多相关文章

  1. Jquery时间快捷控件(Jtime)配置v1.0

    1.脚本代码行 /** * @title 时间工具类 * @note 本类一律违规验证返回false * @author {boonyachengdu@gmail.com} * @date 2013- ...

  2. ExtJs控件属性配置详细

    序言:    1.本文摘自网络,看控件命名像是4.0以前的版本,但控件属性配置仍然可以借鉴(不足之处,以后项目用到时再续完善). Ext.form.TimeField: 配置项:            ...

  3. 基于jQuery 常用WEB控件收集

    Horizontal accordion: jQuery 基于jQuery开发,非常简单的水平方向折叠控件. Horizontal accordion: jQuery jQuery-Horizonta ...

  4. 43. ExtJs控件属性配置详细

    转自:https://www.cnblogs.com/mannixiang/p/6558225.html 序言:    1.本文摘自网络,看控件命名像是4.0以前的版本,但控件属性配置仍然可以借鉴(不 ...

  5. jquery插件——日历控件

    今天在网上有看到一个jquery插件——日历控件,不过之前也在柯乐义的网站上看到了(http://keleyi.com/ 推荐下) 这个插件看着比较大气,所以干脆也分享下,以后自己也好用一点儿 1.页 ...

  6. 弹出框页面中使用jquery.validate验证控件

    弹出框页面中使用jquery.validate验证控件有几个问题需要解决: 1,弹出框的提交事件完成后如何关闭弹出框页面? 2,提交不成功如何返回当前页? 3,如果知道验证事件成功? 之前笔者都是JS ...

  7. SNF开发平台WinForm之十五-时间轴控件使用-SNF快速开发平台3.3-Spring.Net.Framework

    一.显示效果如下: 二.在控件库里选择UCTimeAxis 拖拽到窗体里. 三.加入以下代码,在load事件里进行调用就可以运行了. #region 给时间轴控件加载数据 private void U ...

  8. 给easyui datebox时间框控件扩展一个清空的实例

    给easyui datebox扩展一个清空的实例 步骤一:拓展插件 /** * 给时间框控件扩展一个清除的按钮 */ $.fn.datebox.defaults.cleanText = '清空'; ( ...

  9. 一些基于jQuery开发的控件

    基于jQuery开发,非常简单的水平方向折叠控件.主页:http://letmehaveblog.blogspot.com/2007/10/haccordion-simple-horizontal-a ...

随机推荐

  1. MVC View返回list列表

    );             Sql sql2 = );             Sql sql3 = );             Sql sql4 = );             Sql sql ...

  2. Encode and Decode Strings 解答

    Question Design an algorithm to encode a list of strings to a string. The encoded string is then sen ...

  3. LeetCode198 House Robber

    You are a professional robber planning to rob houses along a street. Each house has a certain amount ...

  4. 【HDU1856】More is better(并查集基础题)

    裸并查集,但有二坑: 1.需要路径压缩,不写的话会TLE 2.根据题目大意,如果0组男孩合作的话,应该最大的子集元素数目为1.所以res初始化为1即可. #include <iostream&g ...

  5. java遍历泛型的方法

    一.List遍历 Java中List遍历有三种方法来遍历泛型,主要为: 1.for循环遍历 2.iterator遍历 3.foreach遍历 package com.gmail.lsgjzhuwei; ...

  6. C++ - 容器(container)的erase()函数

    容器(container)的erase()函数 本文地址: http://blog.csdn.net/caroline_wendy/article/details/23996013 容器(contai ...

  7. fatal error: malformed or corrupted AST file: &#39;Unable to load module &quot;/Users/apple/Library/Developer

    在同一时候安装使用Xcode5, Xcode6之后, 常常遇到这个问题. fatal error: malformed or corrupted AST file: 'Unable to load m ...

  8. 使用Xshell连接Ubuntu

    使用Xshell连接Ubuntu Xshell是一个安全终端模拟软件,可以进行远程登录.我使用XShell的主要目的是在Windows环境下登录Linux终端进行编码,非常方便.本文简单介绍下它的使用 ...

  9. java 中Date的格式化样式

    public static void main(String[] args) { Date d = new Date(); System.out.println(d); // Date类的默认格式 T ...

  10. Js Json 互转

    推荐: //js对象转换为 JSON 文本 var text = '[{"id":1,"name":"C","size" ...