物联网平台 +Web 组态
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 lines
35 KiB

2 years ago
/**
@Name : jeDate v6.0.2 日期控件
@Author: chen guojun
@Date: 2017-11-02
@QQ群516754269
@官网http://www.jemui.com/ 或 https://github.com/singod/jeDate
*/
!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?module.exports=b():a.jeDate=b()}(this,function(){function DateTime(){var a=new Date,b=this;b.reDate=function(){return new DateTime},b.GetValue=function(){return a},b.GetFullYear=function(){return a.getFullYear()},b.GetMonth=function(){return a.getMonth()+1},b.GetHours=function(){return a.getHours()},b.GetDate=function(){return a.getDate()},b.GetMinutes=function(){return a.getMinutes()},b.GetSeconds=function(){return a.getSeconds()}}function jeDate(a,b){this.opts=b,this.valCell=a,this.format=this.opts.format,this.initdates()}var jet,doc,regymdzz,gr,regymd,parseInt,config,searandom,jedfn,jefix,matArr;return $&&$.fn&&$.fn.jquery?(jet={},doc=document,regymdzz="YYYY|MM|DD|hh|mm|ss|zz",gr=/\-/g,regymd="YYYY|MM|DD|hh|mm|ss|zz".replace("|zz",""),parseInt=function(a){return window.parseInt(a,10)},config={skinCell:"jedateblue",language:{name:"cn",month:["01","02","03","04","05","06","07","08","09","10","11","12"],weeks:["日","一","二","三","四","五","六"],times:["小时","分钟","秒数"],titText:"请选择日期时间",clear:"清空",today:"现在",yes:"确定",close:"关闭"},range:!1,trigger:"click",format:"YYYY-MM-DD hh:mm:ss",minDate:"1900-01-01 00:00:00",maxDate:"2099-12-31 23:59:59"},$.fn.jeDate=function(a){return new jeDate($(this),a||{})},$.extend({jeDate:function(a,b){return new jeDate($(a),b||{})}}),jet.isObj=function(a){for(var b in a)return!0;return!1},jet.reMatch=function(a){return a.match(/\w+|d+/g)},jet.docScroll=function(a){return a=a?"scrollLeft":"scrollTop",document.body[a]|document.documentElement[a]},jet.docArea=function(a){return document.documentElement[a?"clientWidth":"clientHeight"]},jet.isLeap=function(a){return 0!==a%100&&0===a%4||0===a%400},jet.digit=function(a){return 10>a?"0"+(0|a):a},jet.isNum=function(a){return/^[+-]?\d*\.?\d*$/.test(a)?!0:!1},jet.getDaysNum=function(a,b){var c=31;switch(parseInt(b)){case 2:c=jet.isLeap(a)?29:28;break;case 4:case 6:case 9:case 11:c=30}return c},jet.getYM=function(a,b,c){var d=new Date(a,b-1);return d.setMonth(b-1+c),{y:d.getFullYear(),m:d.getMonth()+1}},jet.prevMonth=function(a,b,c){return jet.getYM(a,b,0-(c||1))},jet.nextMonth=function(a,b,c){return jet.getYM(a,b,c||1)},jet.parse=function(a,b){return b.replace(new RegExp(regymdzz,"g"),function(b){return"zz"==b?"00":jet.digit(a[b])})},jet.isparmat=function(a){var b=jet.reMatch(a),c=regymdzz.split("|"),d=[];return $.each(c,function(a,c){$.each(b,function(a,b){c==b&&d.push(b)})}),d.join("-")},jet.parseOld=function(a,b,c){a=a.concat(b);var d={},f=(regymdzz.split("|"),jet.reMatch(c));return $.each(a,function(a,b){d[f[a]]=parseInt(b)}),c.replace(new RegExp(regymdzz,"g"),function(a){return"zz"==a?"00":jet.digit(d[a])})},jet.checkFormat=function(a){var b=[];return a.replace(new RegExp(regymdzz,"g"),function(a){b.push(a)}),b.join("-")},jet.splMatch=function(a){var b=a.split(" ");return jet.reMatch(b[0])},jet.mlen=function(a){var b=a.match(/\w+|d+/g).length,c="hh"==a.substring(0,2),d=c&&3>=b?7:b;return d},jet.checkDate=function(a){var b=jet.reMatch(a);if(isNaN(b[0])||isNaN(b[1])||isNaN(b[2]))return!1;if(b[1]>12||b[1]<1)return!1;if(b[2]<1||b[2]>31)return!1;if((4==b[1]||6==b[1]||9==b[1]||11==b[1])&&b[2]>30)return!1;if(2==b[1]){if(b[2]>29)return!1;if((0==b[0]%100&&0!=b[0]%400||0!=b[0]%4)&&b[2]>28)return!1}return!0},jet.GetDateTime=function(a,b){var c,d,e,f;return b=b||"YYYY-MM-DD hh:mm:ss",c=$.extend({YYYY:null,MM:null,DD:null,hh:0,mm:0,ss:0},a),d={YYYY:"FullYear",MM:"Month",DD:"Date",hh:"Hours",mm:"Minutes",ss:"Seconds"},e=(new DateTime).reDate(),$.each(["ss","mm","hh","DD","MM","YYYY"],function(a,b){if(!jet.isNum(parseInt(c[b])))return null;var f=e.GetValue();(parseInt(c[b])||0==parseInt(c[b]))&&f["set"+d[b]](e["Get"+d[b]]()+("MM"==b?-1:0)+parseInt(c[b]))}),f=jet.parse({YYYY:e.GetFullYear(),MM:e.GetMonth(),DD:e.GetDate(),hh:e.GetHours(),mm:e.GetMinutes(),ss:e.GetSeconds()},b)},jet.isValHtml=function(a){return/textarea|input/.test(a[0].tagName.toLocaleLowerCase())},jet.isBool=function(a){return void 0==a||1==a?!0:!1},sea
return new o(new Date(a,b,c))},$.dateVer="6.0.2",$.nowDate=function(a,b){return b=b||"YYYY-MM-DD hh:mm:ss","number"==typeof a&&(a={DD:a}),jet.GetDateTime(a,b)},$.timeStampDate=function(a,b){var c,d,e,f,g,h;if(b=b||"YYYY-MM-DD hh:mm:ss",c=/^(-)?\d{1,10}$/.test(a)||/^(-)?\d{1,13}$/.test(a),/^[1-9]*[1-9][0-9]*$/.test(a)&&c){if(d=parseInt(a),/^(-)?\d{1,10}$/.test(d))d=1e3*d;else if(/^(-)?\d{1,13}$/.test(d))d=1e3*d;else{if(!/^(-)?\d{1,14}$/.test(d))return alert("时间戳格式不正确"),void 0;d=100*d}return e=new Date(d),jet.parse({YYYY:e.getFullYear(),MM:jet.digit(e.getMonth()+1),DD:jet.digit(e.getDate()),hh:jet.digit(e.getHours()),mm:jet.digit(e.getMinutes()),ss:jet.digit(e.getSeconds())},b)}return f=jet.reMatch(a),g=new Date(f[0],parseInt(f[1])-1,f[2],f[3]||0,f[4]||0,f[5]||0),h=Math.round(g.getTime()/1e3),h},$.splitDate=function(a){var b=a.match(/\w+|d+/g);return{YYYY:parseInt(b[0]),MM:parseInt(b[1])||0,DD:parseInt(b[2])||0,hh:parseInt(b[3])||0,mm:parseInt(b[4])||0,ss:parseInt(b[5])||0}},$.getLunar=function(a,b){var d,e,f,c=this;return b=b||"YYYY-MM-DD hh:mm:ss",/YYYY-MM-DD/g.test(jet.isparmat(b))?(d=a.substr(0,4).replace(/^(\d{4})/g,"$1,")+a.substr(4).replace(/(.{2})/g,"$1,"),e=jet.isNum(a)?jet.reMatch(d):jet.reMatch(a),f=c.jeLunar(e[0],e[1]-1,e[2]),{nMonth:f.lnongMonth,nDays:f.lnongDate,yYear:parseInt(f.solarYear),yMonth:parseInt(f.solarMonth),yDays:parseInt(f.solarDate),cWeek:f.inWeekDays,nWeek:f.solarWeekDay}):void 0},jeDate):(alert("在引用jquery.jedate.js之前,先引用jQuery,否则无法使用 jeDate"),void 0)});