├── skin
├── jedate.png
├── jedatefont.eot
├── jedatefont.ttf
├── jedatefont.woff
├── jedatefont.svg
└── jedate.css
├── test
├── jedate.png
├── jeDate-test.css
└── demo.js
├── params.json
├── README.md
├── LICENSE
├── index.html
├── dist
└── jedate.min.js
└── src
└── jedate.js
/skin/jedate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/singod/jeDate/HEAD/skin/jedate.png
--------------------------------------------------------------------------------
/test/jedate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/singod/jeDate/HEAD/test/jedate.png
--------------------------------------------------------------------------------
/skin/jedatefont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/singod/jeDate/HEAD/skin/jedatefont.eot
--------------------------------------------------------------------------------
/skin/jedatefont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/singod/jeDate/HEAD/skin/jedatefont.ttf
--------------------------------------------------------------------------------
/skin/jedatefont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/singod/jeDate/HEAD/skin/jedatefont.woff
--------------------------------------------------------------------------------
/params.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jeDate",
3 | "version": "3.8",
4 | "description": "jeDate日期选择插件除了包含 日历可以直接显示与点击显示、日期标注点、设定年月(YYYY-MM)、日期范围限制、开始日期设定、自定义日期格式、时间戳转换、当天的前后若干天返回、时分秒选择、智能响应、自动纠错、节日识别,操作等常规功能外,还拥有更多趋近完美的解决方案。您可以免费将她用于任何个人项目。但是不能去除头部信息。",
5 | "main": "jedate/jquery.jedate.js",
6 | "homepage": "https://github.com/singod/jeDate",
7 | "repository": {
8 | "type": "git",
9 | "url": "https://github.com/singod/jeDate.git"
10 | },
11 | "keywords": [
12 | "jeDate",
13 | "jedate",
14 | "jeDate日期选择插件",
15 | "日期控件",
16 | "javascript"
17 | ],
18 | "author": "guojun chen <249477145@qq.com> (http://www.jemui.com)",
19 | "license": {
20 | "type": "MIT",
21 | "url": "http://www.jemui.com/license/"
22 | },
23 | "bugs": {
24 | "url": "https://github.com/singod/jeDate/issues"
25 | },
26 | "scripts": {
27 | "test": "mocha-phantomjs index.html",
28 | "start": "gulp watch"
29 | },
30 | "devDependencies": {
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | jeDate.js
2 | =======
3 | jeDate V6.5.0 是一款原生JS开发的 不依赖任何第三方库 大众化的日期控件,她身兼多职,虽不是万能的,但是她却是功能强大多样的美少女,她除了包含 单双面板、区域选择、 多语言、日历固定、有效无效日期、日期时间戳转换、日期加减、限制时分秒、初始化日期加减N、日期标注点、设定年月(YYYY-MM)、日期范围限制、开始日期设定、自定义日期格式、当天的前后若干天返回、时分秒选择、智能响应、自动纠错、节日识别,操作等常规功能外,根据不同的日期格式,显示不同内容,还拥有更多趋近完美的解决方案。更多的是需要你与她的亲密接触与呵护! QQ群:516754269
4 |
5 | **使用方法**
6 |
7 | * [点击查看详细日期API(http://www.jemui.com/uidoc/jedate.html)](http://www.jemui.com/uidoc/jedate.html)
8 |
9 |
10 | # 快速上手
11 |
12 | **使用NPM安装**
13 |
14 | npm install jquery.jedate
15 |
16 | **使用Git安装**
17 |
18 | git clone git://github.com/singod/jeDate.git
19 |
20 | **使用对象**
21 |
22 |
23 |
24 |
25 |
26 | **查看演示**
27 |
28 | * [查看演示](http://singod.github.io/jeDate/)
29 |
30 |
31 | ## License
32 |
33 | [MIT License](https://github.com/singod/jeDate/blob/gh-pages/LICENSE)
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 JEUI
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/jeDate-test.css:
--------------------------------------------------------------------------------
1 | html,body{min-height:100%;}
2 | html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}
3 | body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin: 0;padding: 0;border: 0;outline: 0;-webkit-tap-highlight-color:transparent;}
4 | article,aside,header,footer,nav,section,figure,figcaption,hgroup,progress,canvas{display:block}
5 | blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}
6 | body{font-size:14px;font-family:'PingFangSC-Light','PingFang SC','Segoe UI','Lucida Grande','NotoSansHans-Light','Microsoft YaHei', '\5FAE\8F6F\96C5\9ED1', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif;text-rendering:geometricPrecision;color:#333333;background:#FFFFFF;}
7 |
8 | a:active,a:hover{outline:0}
9 | img{display:inline-block;border:0}
10 | li{list-style:none}
11 | table{border-collapse:collapse;border-spacing:0}
12 | h1,h2,h3{font-size:14px;font-weight:400}
13 | h4,h5,h6{font-size:100%;font-weight:400}
14 | button,input,optgroup,option,select,textarea{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;outline:0;margin: 0px;padding: 0px;}
15 | pre{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}
16 |
17 | hr{height:1px;margin:10px 0;border:0;background-color:#e2e2e2;clear:both}
18 | a{color:#333;text-decoration:none}
19 | a:hover{color:#777}
20 | .gray{background-color: #f2f2f2;}
21 |
22 | .icons{background-image: url("jedate.png"); background-repeat:no-repeat; }
23 | .jequote{max-width: 1200px;margin-bottom: 10px;padding: 15px;line-height: 22px;border: 4px solid #00A080;border-radius: 4px;background-color: #f5f5f5;font-size: 15px;}
24 | .jebody{max-width: 1200px;margin: 40px auto 100px auto;position: relative;}
25 | .jewarp{width:100%;margin: 15px 0; }
26 | .jewarp h3{position: relative;left: 0;height: 40px;line-height:40px;padding-left:10px;white-space: nowrap;border-radius: 4px 4px 0 0;font-size: 16px;color:#00A080;text-align: left;border: 1px solid #ededed;border-bottom: none;}
27 | .jewarp .content{border: 1px solid #ededed;border-radius:0 0 4px 4px;padding: 25px 10px 10px 10px;overflow: hidden;}
28 | .jeitem{width:33.33%;margin:0 0px 15px 0;position: relative;float: left;}
29 | .jelabel{width: 120px;float: left;display: block;padding: 9px 10px;font-weight: 400;text-align: right; color:#555;}
30 | .jeinpbox{width: 230px;margin-right: 10px;float: left;vertical-align: middle;position: relative;}
31 | .jeinput{display: block;width: 100%;padding-left: 10px; height: 36px;line-height: 34px\9;border: 1px solid #e6e6e6;background-color: #fff;border-radius: 3px;background-color: #fcfcfc;}
32 | .jeindiv{display: block;width: 100%;padding-left: 10px; height: 36px;line-height: 36px;border-bottom: 1px solid #e6e6e6;background-color: #fff;background-color: #fcfcfc;}
33 | .jebtns{width: 35px;margin-left: 10px; height: 36px;line-height: 36px\9;border: 1px solid #e6e6e6;background-color: #fff;border-radius: 3px;background-position:right center;float: left;cursor: pointer;position: absolute;top:0;right:-12px;}
34 | .jefixeitem{width:25%;margin:0 0px 15px 0;position: relative;float: left; text-align: center;}
35 |
36 |
--------------------------------------------------------------------------------
/skin/jedatefont.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
46 |
--------------------------------------------------------------------------------
/test/demo.js:
--------------------------------------------------------------------------------
1 | /**
2 | * jeDate 演示
3 | */
4 | var enLang = {
5 | name : "en",
6 | month : ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
7 | weeks : [ "SUN","MON","TUR","WED","THU","FRI","SAT" ],
8 | times : ["Hour","Minute","Second"],
9 | timetxt: ["Time","Start Time","End Time"],
10 | backtxt:"Back",
11 | clear : "Clear",
12 | today : "Now",
13 | yes : "Confirm",
14 | close : "Close"
15 | }
16 | //常规选择
17 | jeDate("#test01",{
18 | //festival:true,
19 | //multiPane:false,
20 | format: "YYYY"
21 | });
22 |
23 | jeDate("#test02",{
24 | format: "YYYY-MM"
25 | });
26 |
27 | jeDate("#test03",{
28 | //onClose:false,
29 |
30 | format: "MM-DD-YYYY"
31 | });
32 | jeDate("#test04",{
33 | festival:true,
34 | minDate:"1900-01-01", //最小日期
35 | maxDate:"2099-12-31", //最大日期
36 | method:{
37 | choose:function (params) {
38 |
39 | }
40 | },
41 | format: "YYYY-MM-DD hh:mm:ss"
42 | });
43 | var jds = jeDate("#test05",{
44 | minDate:"01:02:08", //最小日期
45 | maxDate:"15:25:35", //最大日期
46 | format: "hh:mm:ss"
47 | });
48 | console.log(jds)
49 | //英文语言
50 | jeDate("#enYMD",{
51 | language:enLang,
52 | format: "YYYY-MM-DD"
53 | });
54 | jeDate("#enYMDhms",{
55 | language:enLang,
56 | format: "YYYY-MM-DD hh:mm:ss"
57 | });
58 | jeDate("#enhms",{
59 | language:enLang,
60 | format: "hh:mm:ss"
61 | });
62 |
63 | //自定义主题色
64 | jeDate("#testblue",{
65 | theme:{bgcolor:"#00A1CB",pnColor:"#00CCFF"},
66 | multiPane:false,
67 | range:" ~ ",
68 | format: "YYYY-MM-DD hh:mm:ss"
69 | });
70 | jeDate("#testgray",{
71 | theme:{bgcolor:"#00A680",pnColor:"#00DDAA"},
72 | multiPane:false,
73 | range:" ~ ",
74 | format: "YYYY-MM-DD hh:mm:ss"
75 | });
76 | jeDate("#testred",{
77 | theme:{bgcolor:"#D91600",pnColor:"#FF6653"},
78 | multiPane:false,
79 | range:" ~ ",
80 | format: "YYYY-MM-DD hh:mm:ss"
81 | });
82 |
83 | //区域范围选择
84 | jeDate("#test06",{
85 | format: "YYYY",
86 | range:" ~ "
87 | });
88 | jeDate("#test07",{
89 | format: "YYYY-MM",
90 | range:" To "
91 | });
92 | jeDate("#test08",{
93 | format: "YYYY-MM-DD",
94 | range:" 至 "
95 | });
96 |
97 |
98 | //区域范围双面板选择
99 | var jd = jeDate("#test09",{
100 | format: "YYYY",
101 | multiPane:false,
102 | range:" ~ "
103 | });
104 | jeDate("#test10",{
105 | format: "YYYY-MM",
106 | multiPane:false,
107 | range:" To "
108 | });
109 | jeDate("#test11",{
110 | format: "YYYY-MM-DD",
111 | multiPane:false,
112 | range:" 至 "
113 | });
114 | jeDate("#test11A",{
115 | format: "YYYY-MM-DD hh:mm:ss",
116 | multiPane:false,
117 | range:" 至 "
118 | });
119 | jeDate("#test11B",{
120 | minDate:"03:02:04", //最小日期
121 | maxDate:"14:30:45",
122 | format: "hh:mm:ss",
123 | multiPane:false,
124 | range:" 至 "
125 | });
126 | jeDate("#test11C",{
127 | format: "hh:mm",
128 | multiPane:false,
129 | range:" 至 "
130 | });
131 |
132 | //自定义格式选择
133 | jeDate("#test12",{
134 | format: "YYYY年MM月DD日"
135 | });
136 | jeDate("#test13",{
137 | format: "MM-DD-YYYY"
138 | });
139 | jeDate("#test14",{
140 | format: "DD/MM/YYYY"
141 | });
142 |
143 | //一次绑定多个选择
144 | var jel = document.querySelectorAll(".moredate");
145 | for(var j=0;j jeDate日期控件 - (原生JS) {%=lang.times[0]%} {%=lang.times[1]%} {%=lang.times[2]%}
14 |
19 |
16 | jeDate群01:516754269(已满) jeDate群02:73371254
17 | 此为部分个例展示,更多请看 详细日期控件API。
18 | 常规选择
21 | 英文语言
46 | 自定义主题色
64 | 区域范围选择
82 | 区域范围双面板选择
100 | 自定义格式选择
129 | 一次绑定多个选择
146 | DIV元素选择
163 | 左边多类选择
180 | YYYYMMDD格式
193 | 其它功能展示选择
206 | 有效、无效日期限制
239 | 直接展示日历
268 |
",r='{% for(var y=0;y<=11;y++){ %} {% } %} {% } %} {%=yearlist[i][y].y%}'+g+" {% if((y+1)%3==0){ %}
",s='{% for(var m=0;m<=11;m++){ %} {% } %} {% } %} {%=monthlist[i][m].m%}'+h+" {% if((m+1)%3==0){ %}
',t='{% for(var w=0;w {% for(var d=0;d<=41;d++){ %} {% } %} {% } %} {%=daylist[i][d].day%} {% if((d+1)%7==0){ %} {% for(var s=0;s
'+c+''+g+"
"):d=''+c+"
",d},D=function(a,b,c,d){var e=parseInt(a+""+jet.digit(b)+jet.digit(c));if(d){if(e>=w&&y>=e)return!0}else if(w>e||e>y)return!0},E=function(a,b){var d,f,g,h,i,c=function(a,b){for(var c in b)if(b[c]==a)return!0;return!1};return u.length>0&&""!=u[0]&&(/\%/g.test(u[0])?(d=u[0].replace(/\%/g,"").split(","),f=[],jet.each(d,function(a,b){f.push(jet.digit(parseInt(b)))}),g=0==c(jet.digit(a),f),b=jet.isBool(u[1])?g?" disabled":b:g?b:" disabled"):(h=e.dateRegExp(u[0]),i=h.test(jet.digit(a)),b=jet.isBool(u[1])?i?" disabled":b:i?b:" disabled")),b};for(F=q-j+1;q>=F;F++,f++)G=B(o.y,o.m,F),H=D(o.y,o.m,F,!1)?"disabled":"other",H=E(F,H),g.push({style:H,ymd:o.y+"-"+jet.digit(o.m)+"-"+jet.digit(F),day:C(o.y,o.m,F)+G});for(I=1;l>=I;I++,f++)J=B(a,b,I),K="",L=parseInt(a+""+jet.digit(b)+jet.digit(I)),M=L>z,N=A>L,K=D(a,b,I,!0)?L==z||L==A?" action":M&&N?" contain":"":" disabled",K=E(I,K),g.push({style:"normal"+K,ymd:a+"-"+jet.digit(b)+"-"+jet.digit(I),day:C(a,b,I)+J});for(O=1,P=42-f;P>=O;O++)Q=B(r.y,r.m,O),R=D(r.y,r.m,O,!1)?"disabled":"other",R=E(O,R),g.push({style:R,ymd:r.y+"-"+jet.digit(r.m)+"-"+jet.digit(O),day:C(r.y,r.m,O)+Q});return g},eachTime:function(a,b){var c=this,d=c.$opts,e=d.range,f=d.multiPane,g=[],h=[],i=["hh","mm","ss"],j=[],k="",l=c.format,m=jet.trim(c.minDate).replace(/\s+/g," "),n=jet.trim(c.maxDate).replace(/\s+/g," "),o=m.split(" "),p=n.split(" ");return c.dlen>3&&/\:/.test(o)&&/\:/.test(p)&&(g=jet.reMatch(/\s/.test(m)&&c.dlen>3?o[1]:m),h=jet.reMatch(/\s/.test(n)&&c.dlen>3?p[1]:n)),jet.each([24,60,60],function(d,m){var n,p,q,r;for(j[d]=[],n=void 0==g[d]||0==g[d]?a[i[d]]:g[d],p=""==c.getValue()?n:a[i[d]],c.dlen>3&&/\:/.test(o)&&1==b&&(c.selectTime[0][i[d]]=p),q=0;m>q;q++)r=new RegExp(i[d],"g").test(l),k=q==p?r?"action":"disabled":!r||!e&&f&&(q农历:'+c.shengxiao+"年 "+c.lnongMonth+"月"+c.lnongDate+"
"+c.ganzhiYear+"年 "+c.ganzhiMonth+"月 "+c.ganzhiDate+"日
",g=""!=(c.solarFestival||c.lunarFestival)?''+("节日:"+c.solarFestival+c.lunarFestival)+"
":"",h=""!=c.jieqi?''+(""!=c.jieqi?"节气:"+c.jieqi:"")+"
":"",i=""!=(c.solarFestival||c.lunarFestival||c.jieqi)?g+h:"",jet.html(f,d+i),document.body.appendChild(f),j=a.lunarOrien(f,this),jet.setCss(f,{zIndex:void 0==b.zIndex?10005:b.zIndex+5,top:j.top,left:j.left,position:"absolute",display:"block"}))}),jet.on(d,"mouseout",function(){document.body.removeChild($Q("#jedatetipscon"))})}),1!==a.dateCell.nodeType||jet.hasClass(a.dateCell,"grid")||(a.dateCell.className=a.dateCell.className+" grid")},lunarOrien:function(a,b,c){var d,e,f,g,h=b.getBoundingClientRect(),i=a.offsetWidth,j=a.offsetHeight;return e=h.right+i/1.5>=jet.docArea(!0)?h.right-i:h.left+(c?0:jet.docScroll(!0)),d=h.bottom+j/1<=jet.docArea()?h.bottom-1:h.top>j/1.5?h.top-j-1:jet.docArea()-j,e+i>jet.docArea(!0)&&(e=h.left-(i-h.width)),f=Math.max(d+(c?0:jet.docScroll())+1,1)+"px",g=e+"px",{top:f,left:g}},dateOrien:function(a,b,c){var g,h,j,k,d=this,i=d.$opts.fixed?b.getBoundingClientRect():a.getBoundingClientRect(),f=i.left,e=i.bottom;d.$opts.fixed?(j=a.offsetWidth,k=a.offsetHeight,f+j>jet.docArea(!0)&&(f-=j-i.width),e+k>jet.docArea()&&(e=i.top>k?i.top-k-2:jet.docArea()-k-1),g=Math.max(e+(c?0:jet.docScroll())+1,1)+"px",h=f+"px"):(g="50%",h="50%",a.style.cssText="marginTop:"+-(i.height/2)+";marginLeft:"+-(i.width/2)),jet.setCss(a,{top:g,left:h})},tips:function(a,b){var e,c=this,d=$Q(".jedate-tips",c.dateCell);jet.html(d,a||""),jet.setCss(d,{display:"block"}),clearTimeout(e),e=setTimeout(function(){jet.html(d,""),jet.setCss(d,{display:"none"})},1e3*(b||2.5))},locateScroll:function(){var a=this,b=$Q(".jedate-time",a.dateCell).querySelectorAll("ul");jet.each(b,function(a,b){var c=b.querySelector(".action");b.scrollTop=c?c.offsetTop-145:0}),7!=a.dlen&&jet.setCss($Q(".jedate-time",a.dateCell),{display:"none"})}}),jeDate}); -------------------------------------------------------------------------------- /src/jedate.js: -------------------------------------------------------------------------------- 1 | /** 2 | @Name : jeDate v6.5.0 日期控件 3 | @Author: chen guojun 4 | @Date: 2018-04-30 5 | @QQ群:516754269 6 | @官网:http://www.jemui.com/ 或 https://github.com/singod/jeDate 7 | */ 8 | ;(function(window, factory) { 9 | //amd 10 | if (typeof define === 'function' && define.amd) { 11 | define(factory); 12 | } else if (typeof exports === 'object') { //umd 13 | module.exports = factory(); 14 | } else { 15 | window.jeDate = factory(); 16 | } 17 | })(this, function() { 18 | var doc = document, win = window; 19 | var jet = {}, doc = document, regymdzz = "YYYY|MM|DD|hh|mm|ss|zz", gr = /\-/g, 20 | regymd = "YYYY|MM|DD|hh|mm|ss|zz".replace("|zz",""), parseInt = function (n) { return window.parseInt(n, 10);}; 21 | var $Q = function (selector,content) { 22 | content = content || document; 23 | return selector.nodeType ? selector : content.querySelector(selector); 24 | }; 25 | var jeDate = function(elem,options){ 26 | var opts = typeof (options) === "function" ? options() : options; 27 | return new jeDatePick(elem,opts); 28 | }; 29 | //日期控件版本 30 | jeDate.dateVer = "V6.5.0"; 31 | //用一个或多个其他对象来扩展一个对象,返回被扩展的对象 32 | jeDate.extend = jet.extend = function () { 33 | var options, name, src, copy,deep = false, target = arguments[0], i = 1, length = arguments.length; 34 | if (typeof (target) === "boolean") deep = target, target = arguments[1] || {}, i = 2; 35 | if (typeof (target) !== "object" && typeof (target) !== "function") target = {}; 36 | if (length === i) target = this, --i; 37 | for (; i < length; i++) { 38 | if ((options = arguments[i]) != null) { 39 | for (name in options) { 40 | src = target[name], copy = options[name]; 41 | if (target === copy) continue; 42 | if (copy !== undefined) target[name] = copy; 43 | } 44 | } 45 | } 46 | return target; 47 | }; 48 | //返回指定日期 49 | jeDate.nowDate = function (val,format) { 50 | format = format || 'YYYY-MM-DD hh:mm:ss'; 51 | if (!isNaN(val)) val = {DD: val}; 52 | return jet.parse(jet.getDateTime(val),format); 53 | }; 54 | //日期转换 55 | jeDate.convert = function (obj) { 56 | obj.format = obj.format || 'YYYY-MM-DD hh:mm:ss'; 57 | obj.addval = obj.addval || []; 58 | var mats = jet.reMatch(obj.format),objVal = {}; 59 | jet.each(jet.reMatch(obj.val),function (i,cval) { 60 | objVal[mats[i]] = parseInt(cval); 61 | }); 62 | var result = new DateTime(obj.addval,objVal), redate = { 63 | YYYY:result.GetYear(), MM:result.GetMonth(), DD:result.GetDate(), 64 | hh:result.GetHours(), mm:result.GetMinutes(), ss:result.GetSeconds() 65 | }; 66 | return redate; 67 | }; 68 | jeDate.valText = function (elem,value) { 69 | return jet.valText(elem,value); 70 | } 71 | //日期时间戳相互转换 72 | jeDate.timeStampDate = function (date,format) { 73 | format = format || 'YYYY-MM-DD hh:mm:ss'; 74 | var dateTest = (/^(-)?\d{1,10}$/.test(date) || /^(-)?\d{1,13}$/.test(date)); 75 | if(/^[1-9]*[1-9][0-9]*$/.test(date) && dateTest){ 76 | var vdate = parseInt(date); 77 | if (/^(-)?\d{1,10}$/.test(vdate)) { 78 | vdate = vdate * 1000; 79 | } else if (/^(-)?\d{1,13}$/.test(vdate)) { 80 | vdate = vdate * 1000; 81 | } else if (/^(-)?\d{1,14}$/.test(vdate)) { 82 | vdate = vdate * 100; 83 | } else { 84 | alert("时间戳格式不正确"); 85 | return; 86 | } 87 | var setdate = new Date(vdate); 88 | return jet.parse({ 89 | YYYY:setdate.getFullYear(), MM:jet.digit(setdate.getMonth()+1), DD:jet.digit(setdate.getDate()) , 90 | hh:jet.digit(setdate.getHours()), mm:jet.digit(setdate.getMinutes()), ss:jet.digit(setdate.getSeconds()) 91 | }, format); 92 | }else { 93 | //将日期转换成时间戳 94 | var arrs = jet.reMatch(date), 95 | newdate = new Date(arrs[0],arrs[1]-1,arrs[2],arrs[3]||0,arrs[4]||0,arrs[5]||0), 96 | timeStr = Math.round(newdate.getTime() / 1000); 97 | return timeStr; 98 | } 99 | }; 100 | //获取年月日星期 101 | jeDate.getLunar = function(obj){ 102 | //如果为数字类型的日期对获取到日期的进行替换 103 | var lunars = jeLunar(obj.YYYY, parseInt(obj.MM) - 1, obj.DD); 104 | return{ 105 | nM: lunars.lnongMonth, //农历月 106 | nD: lunars.lnongDate, //农历日 107 | cY: parseInt(lunars.solarYear), //阳历年 108 | cM: parseInt(lunars.solarMonth), //阳历月 109 | cD: parseInt(lunars.solarDate), //阳历日 110 | cW: lunars.inWeekDays, //汉字星期几 111 | nW: lunars.solarWeekDay //数字星期几 112 | }; 113 | }; 114 | //转换日期格式 115 | jeDate.parse = jet.parse = function(ymdhms, format) { 116 | return format.replace(new RegExp(regymdzz,"g"), function(str, index) { 117 | return str == "zz" ? "00":jet.digit(ymdhms[str]); 118 | }); 119 | } 120 | //返回日期 121 | function DateTime(arr,valObj) { 122 | var that = this,newdate = new Date(), narr = ["FullYear","Month","Date","Hours","Minutes","Seconds"]; 123 | var vb = jet.extend({YYYY:null,MM:null,DD:null,hh:newdate.getHours(),mm:newdate.getMinutes(),ss:newdate.getSeconds()},valObj); 124 | var ND = valObj == undefined ? newdate : new Date(vb.YYYY,vb.MM,vb.DD,vb.hh,vb.mm,vb.ss); 125 | if((arr||[]).length>0) jet.each(arr,function (i,par) { 126 | ND["set"+narr[i]](narr[i] == "Month" ? parseInt(par)-1:parseInt(par)); 127 | }); 128 | //返回一个数值相同的新DateTime对象 129 | that.reDate = function () { 130 | return new DateTime(); 131 | }; 132 | //返回此实例的Date值 133 | that.GetValue = function () { 134 | return ND; 135 | }; 136 | //获取此实例所表示日期的年份部分。 137 | that.GetYear = function () { 138 | return ND.getFullYear(); 139 | }; 140 | //获取此实例所表示日期的月份部分。 141 | that.GetMonth = function () { 142 | return ND.getMonth() + 1; 143 | }; 144 | //获取此实例所表示的日期为该月中的第几天。 145 | that.GetDate = function () { 146 | return ND.getDate(); 147 | }; 148 | //获取此实例所表示日期的小时部分。 149 | that.GetHours = function () { 150 | return ND.getHours(); 151 | }; 152 | //获取此实例所表示日期的分钟部分。 153 | that.GetMinutes = function () { 154 | return ND.getMinutes(); 155 | }; 156 | //获取此实例所表示日期的秒部分。 157 | that.GetSeconds = function () { 158 | return ND.getSeconds(); 159 | }; 160 | }; 161 | 162 | jet.extend(jet,{ 163 | isType : function (obj,type) { 164 | var firstUper = function (str) { 165 | str = str.toLowerCase(); 166 | return str.replace(/\b(\w)|\s(\w)/g, function (m) { 167 | return m.toUpperCase(); 168 | }); 169 | } 170 | return Object.prototype.toString.call(obj) == "[object " + firstUper(type) + "]"; 171 | }, 172 | each : function (obj, callback, args) { 173 | var name, i = 0, length = obj.length, iselem = (length === undefined || obj === "function"); 174 | if (iselem) { 175 | for (name in obj) { if (callback.call(obj[name], name, obj[name]) === false) { break } } 176 | } else { 177 | for (; i < length;) { if (callback.call(obj[i], i, obj[i++]) === false) { break } } 178 | } 179 | return obj; 180 | }, 181 | on : function (elm, type, fn) { 182 | if (elm.addEventListener) { 183 | elm.addEventListener(type, fn, false);//DOM2.0 184 | return true; 185 | }else if (elm.attachEvent) { 186 | return elm.attachEvent("on" + type, fn);//IE5+ 187 | }else { 188 | elm["on" + type] = fn;//DOM 0 189 | } 190 | }, 191 | isObj : function (obj){ 192 | for(var i in obj){return true;} 193 | return false; 194 | }, 195 | trim : function (str){ return str.replace(/(^\s*)|(\s*$)/g, ""); }, 196 | reMatch : function (str) { 197 | var smarr = [],maStr = "", parti = /(^\w{4}|\w{2}\B)/g; 198 | if(jet.isNum(str)){ 199 | maStr = str.replace(parti,"$1-"); 200 | }else{ 201 | maStr = /^[A-Za-z]+$/.test(str) ? str.replace(parti,"$1-") : str; 202 | } 203 | jet.each(maStr.match(/\w+|d+/g),function (i,val) { 204 | smarr.push(jet.isNum(val) ? parseInt(val):val); 205 | }); 206 | return smarr; 207 | }, 208 | equals : function (arrA,arrB) { 209 | if (!arrB) return false; 210 | if (arrA.length != arrB.length) return false; 211 | for (var i = 0, l = arrA.length; i < l; i++) { 212 | if (arrA[i] instanceof Array && arrB[i] instanceof Array) { 213 | if (!arrA[i].equals(arrB[i])) return false; 214 | } else if (arrA[i] != arrB[i]) { 215 | return false; 216 | } 217 | } 218 | return true; 219 | }, 220 | docScroll : function(type) { 221 | type = type ? "scrollLeft" :"scrollTop"; 222 | return document.body[type] | document.documentElement[type]; 223 | }, 224 | docArea : function(type) { 225 | return document.documentElement[type ? "clientWidth" :"clientHeight"]; 226 | }, 227 | //补齐数位 228 | digit : function(num) { 229 | return num < 10 ? "0" + (num | 0) :num; 230 | }, 231 | //判断是否为数字 232 | isNum : function(value){ 233 | return /^[+-]?\d*\.?\d*$/.test(value) ? true : false; 234 | }, 235 | //获取本月的总天数 236 | getDaysNum : function(y, m) { 237 | var num = 31,isLeap = (y % 100 !== 0 && y % 4 === 0) || (y % 400 === 0); 238 | switch (parseInt(m)) { 239 | case 2: num = isLeap ? 29 : 28; break; 240 | case 4: case 6: case 9: case 11: num = 30; break; 241 | } 242 | return num; 243 | }, 244 | //获取月与年 245 | getYM : function(y, m, n) { 246 | var nd = new Date(y, m - 1); 247 | nd.setMonth(m - 1 + n); 248 | return { 249 | y: nd.getFullYear(), 250 | m: nd.getMonth() + 1 251 | }; 252 | }, 253 | //获取上个月 254 | prevMonth : function(y, m, n) { 255 | return jet.getYM(y, m, 0 - (n || 1)); 256 | }, 257 | //获取下个月 258 | nextMonth : function(y, m, n) { 259 | return jet.getYM(y, m, n || 1); 260 | }, 261 | setCss:function(elem,obj) { 262 | for (var x in obj) elem.style[x] = obj[x]; 263 | }, 264 | html : function (elem,html) { 265 | return typeof html === "undefined" ? elem && elem.nodeType === 1 ? elem.innerHTML :undefined :typeof html !== "undefined" && html == true ? elem && elem.nodeType === 1 ? elem.outerHTML :undefined : elem.innerHTML = html; 266 | 267 | }, 268 | // 读取设置节点文本内容 269 | text : function(elem,value) { 270 | var innText = document.all ? "innerText" :"textContent"; 271 | return typeof value === "undefined" ? elem && elem.nodeType === 1 ? elem[innText] :undefined : elem[innText] = value; 272 | }, 273 | //设置值 274 | val : function (elem,value) { 275 | if (typeof value === "undefined") { 276 | return elem && elem.nodeType === 1 && typeof elem.value !== "undefined" ? elem.value :undefined; 277 | } 278 | // 将value转化为string 279 | value = value == null ? "" :value + ""; 280 | elem.value = value; 281 | }, 282 | attr : function(elem,value){ 283 | return elem.getAttribute(value); 284 | }, 285 | hasClass : function (obj, cls) { 286 | return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')); 287 | }, 288 | stopPropagation : function (ev) { 289 | (ev && ev.stopPropagation) ? ev.stopPropagation() : window.event.cancelBubble = true; 290 | }, 291 | template : function (str, data) { 292 | var strCell = !/[^\w\-\.:]/.test(str) ? document.getElementById(str).innerHTML : str; 293 | var keys = function (obj){ 294 | var arr = []; 295 | for(arr[arr.length] in obj); 296 | return arr ; 297 | }, dataVar = function (obj) { 298 | var vars = ''; 299 | for (var key in obj) { 300 | vars += 'var ' + key + '= $D["' + key + '"];'; 301 | } 302 | return vars; 303 | }, compile = function (source,data) { 304 | var code = "var $out='" + source.replace(/[\r\n]/g, '').replace(/^(.+?)\{\%|\%\}(.+?)\{\%|\%\}(.+?)$/g, function (val) { 305 | return val.replace(/(['"])/g, '\\\$1'); 306 | }).replace(/\{\%\s*=\s*(.+?)\%\}/g, "';$out+=$1;$out+='").replace(/\{\%(.+?)\%\}/g, "';$1;$out+='") + "';return new String($out);"; 307 | var vars = dataVar(data), Render = new Function('$D',vars + code); 308 | return new Render(data) + ''; 309 | }; 310 | return compile(strCell,data); 311 | }, 312 | 313 | //判断元素类型 314 | isValDiv : function(elem) { 315 | return /textarea|input/.test(elem.tagName.toLocaleLowerCase()); 316 | }, 317 | valText : function (elem,value) { 318 | var cell = $Q(elem) ,type = jet.isValDiv(cell) ? "val" : "text"; 319 | if(value != undefined){ 320 | jet[type](cell,value); 321 | }else{ 322 | return jet[type](cell); 323 | } 324 | }, 325 | isBool : function(obj){ return (obj == undefined || obj == true ? true : false); }, 326 | //获取返回的日期 327 | getDateTime : function (obj) { 328 | var result = new DateTime(), objVal = jet.extend({YYYY:null,MM:null,DD:null,hh:0,mm:0,ss:0},obj), 329 | matArr = {YYYY:"FullYear",MM:"Month",DD:"Date",hh:"Hours",mm:"Minutes",ss:"Seconds"}; 330 | jet.each(["ss","mm","hh","DD","MM","YYYY"],function (i,mat) { 331 | if (!jet.isNum(parseInt(objVal[mat]))) return null; 332 | var reVal = result.GetValue(); 333 | if (parseInt(objVal[mat]) || parseInt(objVal[mat]) == 0){ 334 | reVal["set"+matArr[mat]](result["Get"+matArr[mat]]() + (mat == "MM" ? -1 : 0) + parseInt(objVal[mat])); 335 | } 336 | }); 337 | //获取格式化后的日期 338 | var redate = { 339 | YYYY:result.GetYear(), MM:result.GetMonth(), DD:result.GetDate(), 340 | hh:result.GetHours(), mm:result.GetMinutes(), ss:result.GetSeconds() 341 | }; 342 | return redate; 343 | } 344 | }); 345 | 346 | function jeDatePick(elem, options){ 347 | var config = { 348 | language:{ 349 | name : "cn", 350 | month : ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"], 351 | weeks : [ "日", "一", "二", "三", "四", "五", "六" ], 352 | times : ["小时","分钟","秒数"], 353 | timetxt: ["时间选择","开始时间","结束时间"], 354 | backtxt:"返回日期", 355 | clear : "清空", 356 | today : "现在", 357 | yes : "确定" 358 | }, 359 | format:"YYYY-MM-DD hh:mm:ss", //日期格式 360 | minDate:"1900-01-01 00:00:00", //最小日期 361 | maxDate:"2099-12-31 23:59:59", //最大日期 362 | isShow:true, //是否显示为固定日历,为false的时候固定显示 363 | multiPane:true, //是否为双面板,为false是展示双面板 364 | onClose:true, //是否为选中日期后关闭弹层,为false时选中日期后关闭弹层 365 | range:false, //如果不为空且不为false,则会进行区域选择,例如 " 至 "," ~ "," To " 366 | trigger:"click", //是否为内部触发事件,默认为内部触发事件 367 | position:[], //自定义日期弹层的偏移位置,长度为0,弹层自动查找位置 368 | valiDate:[], //有效日期与非有效日期,例如 ["0[4-7]$,1[1-5]$,2[58]$",true] 369 | isinitVal:false, //是否初始化时间,默认不初始化时间 370 | initDate:{}, //初始化时间,加减 天 时 分 371 | isTime:true, //是否开启时间选择 372 | isClear:true, //是否显示清空按钮 373 | isToday:true, //是否显示今天或本月按钮 374 | isYes:true, //是否显示确定按钮 375 | festival:false, //是否显示农历节日 376 | fixed:true, //是否静止定位,为true时定位在输入框,为false时居中定位 377 | zIndex:2099, //弹出层的层级高度 378 | method:{}, //自定义方法 379 | theme:{}, //自定义主题色 380 | shortcut:[], //日期选择的快捷方式 381 | donefun:null, //选中日期完成的回调 382 | before:null, //在界面加载之前执行 383 | succeed:null //在界面加载之后执行 384 | }; 385 | this.$opts = jet.extend(config,options||{}); 386 | this.valCell = $Q(elem); 387 | this.format = this.$opts.format; 388 | this.valCell != null ? this.init() : alert(elem+" ID\u6216\u7C7B\u540D\u4E0D\u5B58\u5728!"); 389 | jet.extend(this,this.$opts.method); 390 | delete this.$opts.method; 391 | } 392 | var searandom = function (){ 393 | var str = "",arr = [1,2,3,4,5,6,7,8,9,0]; 394 | for(var i=0; i<8; i++) str += arr[Math.round(Math.random() * (arr.length-1))]; 395 | return str; 396 | }; 397 | 398 | var jefix = "jefixed",ymdzArr = jet.reMatch(regymdzz),elx = "#jedate"; 399 | jet.extend(jeDatePick.prototype,{ 400 | init : function () { 401 | var that = this, opts = that.$opts, newDate = new Date(), shortArr = [], 402 | trigges = opts.trigger,ndate = opts.initDate || [], inVal, range = opts.range, 403 | zIndex = opts.zIndex == undefined ? 10000 : opts.zIndex,isShow = jet.isBool(opts.isShow), 404 | isinitVal = (opts.isinitVal == undefined || opts.isinitVal == false) ? false : true; 405 | that.setDatas(); 406 | opts.before && opts.before(that.valCell); 407 | //为开启初始化的时间设置值 408 | if (isinitVal && trigges && isShow) { 409 | if (ndate[1]){ 410 | var addval = jet.getDateTime(ndate[0]); 411 | inVal = [{ 412 | YYYY:addval.YYYY, MM:jet.digit(addval.MM), DD:jet.digit(addval.DD) , 413 | hh:jet.digit(addval.hh), mm:jet.digit(addval.mm), ss:jet.digit(addval.ss) 414 | }]; 415 | }else { 416 | inVal = that.getValue(jet.isObj(ndate[0]) ? ndate[0] : {}); 417 | } 418 | if(!range) that.setValue([inVal[0]],opts.format,true); 419 | } 420 | 421 | var getCurrValue = function () { 422 | var mats = jet.reMatch(that.format), isEmpty = that.getValue() != "",curVal = [], 423 | parmat = that.dlen == 7 ? "hh:mm:ss" : "YYYY-MM"+ (that.dlen <= 2 ? "":"-DD"); 424 | var result = that.valCell.value; 425 | if (!result) { 426 | that.selectValue = [jet.parse(jet.getDateTime({}), parmat)]; 427 | } else { 428 | result = result.substr(0,11); 429 | var nowTime = [jet.parse(jet.getDateTime({}), parmat)]; 430 | nowTime = nowTime[0]; 431 | var time1 = new Date(result).setHours('0'); 432 | var time2 = new Date(nowTime).setHours('0'); 433 | var nDays = (parseInt((time1 - time2) / 1000 / 3600 / 24)); 434 | var redate = { 435 | DD: nDays 436 | }; 437 | that.selectValue = [jet.parse(jet.getDateTime(redate), parmat)]; 438 | } 439 | // that.selectValue = that.selectValue && that.selectValue.length > 0 ? that.selectValue : [jet.parse(jet.getDateTime({}), parmat)]; 440 | 441 | if(isEmpty && isShow){ 442 | var getVal = that.getValue().split(range); 443 | jet.each(new Array(range ? 2 : 1),function (a) { 444 | curVal[a] = {}; 445 | jet.each(jet.reMatch(getVal[a]),function (i,val) { 446 | curVal[a][mats[i]] = parseInt(val); 447 | }); 448 | }); 449 | if(range) that.selectValue = getVal; 450 | }else{ 451 | var parr = that.getValue({})[0], nmVal = jet.nextMonth(parr.YYYY,parr.MM||jet.getDateTime({}).MM), 452 | narr = (that.dlen>2 && that.dlen <=6) ? {YYYY:nmVal.y,MM:nmVal.m} : {}; 453 | curVal = [parr]; 454 | } 455 | that.selectDate = curVal; 456 | return curVal; 457 | },ymarr = []; 458 | that.minDate = ""; that.maxDate = ""; 459 | if(!isShow || !trigges) ymarr = getCurrValue(); 460 | if(!isShow || !trigges){ 461 | that.minDate = jet.isType(opts.minDate,"function") ? opts.minDate(that) : opts.minDate; 462 | that.maxDate = jet.isType(opts.maxDate,"function") ? opts.maxDate(that) : opts.maxDate; 463 | that.storeData(ymarr[0],ymarr[1]); 464 | that.renderDate(); 465 | opts.succeed && opts.succeed(that.dateCell); 466 | }else{ 467 | if (trigges) { 468 | jet.on(that.valCell,trigges,function(){ 469 | if (document.querySelectorAll(elx).length > 0) return; 470 | var gvarr = getCurrValue(); 471 | that.minDate = jet.isType(opts.minDate,"function") ? opts.minDate(that) : opts.minDate; 472 | that.maxDate = jet.isType(opts.maxDate,"function") ? opts.maxDate(that) : opts.maxDate; 473 | that.storeData(gvarr[0],gvarr[1]); 474 | that.renderDate(); 475 | }); 476 | } 477 | } 478 | }, 479 | setDatas : function(){ 480 | var that = this, opts = that.$opts,range = opts.range,shortArr = [],isShow = jet.isBool(opts.isShow),multi = opts.multiPane; 481 | that.$data = jet.extend({year:false,month:false,day:true,time:false,timebtn:false},{ 482 | shortcut:[],lang:opts.language,yaerlist:[],monthlist:[[],[]],ymlist:[[],[]], daylist:[[],[]], 483 | clear:opts.isClear,today:range ? false:opts.isToday,yes:opts.isYes,pane:multi ? 1:2 484 | }); 485 | if(opts.shortcut.length>0){ 486 | jet.each(opts.shortcut,function (i,short) { 487 | var tarr = [], shval = jet.isType(short.val,"function") ? short.val() : short.val; 488 | if(jet.isType(shval,"object")){ 489 | for (var s in shval) tarr.push(s + ':' + shval[s]); 490 | shortArr.push(jet.extend({},{name:short.name,val:"{" + tarr.join('#') + "}"})); 491 | } 492 | }); 493 | that.$data.shortcut = shortArr; 494 | } 495 | that.dlen = (function () { 496 | var mats = jet.reMatch(that.format),marr = []; 497 | jet.each(ymdzArr,function(i,val){ 498 | jet.each(mats,function(m,mval){ 499 | if(val == mval) marr.push(mval); 500 | }); 501 | }); 502 | var matlen = marr.length, lens = (marr[0] == "hh")&&matlen<=3 ? 7 : matlen; 503 | return lens; 504 | })(); 505 | that.$data.dlen = that.dlen; 506 | that.timeInspect = false; 507 | if(that.dlen == 1){ 508 | jet.extend(that.$data,{year:true,day:false}); 509 | }else if(that.dlen == 2){ 510 | jet.extend(that.$data,{month:true,day:false}); 511 | }else if(that.dlen>3 && that.dlen <=6){ 512 | that.$data.timebtn = true; 513 | }else if(that.dlen == 7){ 514 | jet.extend(that.$data,{day:false,time:true}); 515 | } 516 | if(!isShow){ 517 | that.$data.clear = false; 518 | that.$data.yes = false; 519 | } 520 | }, 521 | renderDate : function () { 522 | var that= this, opts = that.$opts,isShow = jet.isBool(opts.isShow), 523 | elxID = !isShow ? elx+searandom() : elx, setzin = {"zIndex": (opts.zIndex == undefined ? 10000 : opts.zIndex)}; 524 | if(that.dateCell == undefined){ 525 | that.dateCell = document.createElement("div"); 526 | that.dateCell.id = elxID.replace(/\#/g,""); 527 | that.dateCell.className = elx.replace(/\#/g,"")+" "+(opts.shortcut.length>0?" leftmenu":""); 528 | that.dateCell.setAttribute("author","chen guojun"); 529 | } 530 | jet.html(that.dateCell,jet.template(that.dateTemplate(),that.$data)); 531 | //自定义主题色 532 | if(jet.isObj(opts.theme)){ 533 | var styleDiv = document.createElement("style"),stCell = ".jedate"+searandom(), t = opts.theme, 534 | BG = "background-color:"+t.bgcolor, WC = "color:"+(t.color == undefined ? "#FFFFFF":t.color), 535 | OTH = (t.pnColor == undefined ? "":"color:"+t.pnColor+";"); 536 | that.dateCell.className = that.dateCell.className+" "+stCell.replace(/^./g,""); styleDiv.setAttribute("type","text/css"); 537 | styleDiv.innerHTML = stCell+" .jedate-menu p:hover{"+BG+";"+WC+";}"+stCell+" .jedate-header em{"+WC+";}"+ 538 | stCell+" .jedate-content .yeartable td.action span,"+stCell+" .jedate-content .monthtable td.action span,"+ 539 | stCell+" .jedate-content .yeartable td.action span:hover,"+stCell+" .jedate-content .monthtable td.action span:hover{"+BG+";border:1px "+t.bgcolor+" solid;"+WC+";}"+stCell+" .jedate-content .daystable td.action,"+stCell+" .jedate-content .daystable td.action:hover,"+ 540 | stCell+" .jedate-content .daystable td.action .lunar,"+stCell+" .jedate-header,"+stCell+" .jedate-time .timeheader,"+ 541 | stCell+" .jedate-time .hmslist ul li.action,"+stCell+" .jedate-time .hmslist ul li.action:hover,"+ 542 | stCell+" .jedate-time .hmslist ul li.disabled.action,"+stCell+" .jedate-footbtn .timecon,"+stCell+" .jedate-footbtn .btnscon span{"+BG+";"+WC+";}"+ 543 | stCell+" .jedate-content .daystable td.other,"+stCell+" .jedate-content .daystable td.other .nolunar,"+stCell+" .jedate-content .daystable td.other .lunar{"+OTH+"}"+stCell+" .jedate-content .daystable td.contain,"+stCell+" .jedate-content .daystable td.contain:hover{background-"+OTH+"}"; 544 | that.dateCell.appendChild(styleDiv); 545 | } 546 | 547 | that.compileBindNode(that.dateCell); 548 | if (document.querySelectorAll(elxID).length > 0) document.body.removeChild($Q(elxID)); 549 | !isShow ? that.valCell.appendChild(that.dateCell) : document.body.appendChild(that.dateCell); 550 | jet.setCss(that.dateCell,jet.extend({position:(!isShow ? "relative" : (opts.fixed == true ? "absolute" :"fixed"))},isShow ? setzin:{})); 551 | that.methodEventBind(); 552 | if(that.dlen == 7 || (that.dlen>3 && that.dlen <=6)) that.locateScroll(); 553 | if(opts.festival && opts.language.name == "cn") that.showFestival(); 554 | if(isShow){ 555 | that.dateOrien(that.dateCell,that.valCell); 556 | that.blankArea(); 557 | } 558 | 559 | }, 560 | //设置日期值 561 | setValue : function (fnStr,matStr,bool) { 562 | var that = this, valCell = that.valCell,strVal; 563 | matStr = matStr || that.format; 564 | if((typeof fnStr=='string')&&fnStr!=''){ 565 | var sprange = fnStr.split(that.$opts.range), inArr=[]; 566 | jet.each(sprange,function (i,sval) { 567 | var reVal = jet.reMatch(sval), inObj={}; 568 | jet.each(jet.reMatch(matStr),function (r,val) { 569 | inObj[val] = reVal[r]; 570 | }); 571 | inArr.push(inObj); 572 | }); 573 | strVal = inArr; 574 | }else { 575 | strVal = fnStr; 576 | } 577 | var vals = that.parseValue(strVal,matStr); 578 | if (bool != false) jet.valText(valCell,vals); 579 | return vals; 580 | }, 581 | //获取日期值 582 | getValue : function (valobj) { 583 | var that = this, valCell = that.valCell, 584 | opts = that.$opts, reObj, result = new DateTime().reDate(), 585 | dateY = result.GetYear(),dateM = result.GetMonth(),dateD = result.GetDate(), 586 | timeh = result.GetHours(),timem = result.GetMinutes(),times = result.GetSeconds(); 587 | if (valobj == undefined && jet.isBool(opts.isShow)){ 588 | reObj = jet.valText(valCell); 589 | }else { 590 | var isValShow = jet.isBool(opts.isShow) ? (jet.valText(valCell) == "") : !jet.isBool(opts.isShow), 591 | objarr = jet.extend({YYYY:null,MM:null,DD:null},valobj||{}), 592 | ranMat = [],newArr = new Array(2),unObj = function (obj) { 593 | return [(objarr[obj] == undefined || objarr[obj] == null),objarr[obj]]; 594 | }, defObj = [{ YYYY:dateY,MM:dateM,DD:dateD, hh:timeh,mm:timem,ss:times,zz:00}, 595 | { YYYY:dateY,MM:dateM,DD:dateD, hh:timeh,mm:timem,ss:times,zz:00}]; 596 | if (isValShow) { 597 | //目标为空值则获取当前日期时间 598 | jet.each(newArr,function (i) { 599 | var inObj = {}; 600 | jet.each(ymdzArr, function (r, val) { 601 | inObj[val] = parseInt(unObj(val)[0] ? defObj[i][val] : unObj(val)[1]); 602 | }); 603 | ranMat.push(jet.extend(defObj[i], inObj)); 604 | }); 605 | } else { 606 | var isunRange = opts.range != false, initVal = that.getValue(), 607 | spVal = initVal.split(opts.range), reMat = jet.reMatch(that.format); 608 | jet.each(newArr,function (i) { 609 | var inObj = {}, reVal = isunRange ? jet.reMatch(spVal[i]) : jet.reMatch(initVal); 610 | jet.each(reMat,function (r,val) { 611 | inObj[val] = reVal[r]; 612 | }); 613 | var exVal = jet.extend(inObj,valobj||{}); 614 | ranMat.push(jet.extend(defObj[i],exVal)); 615 | }); 616 | } 617 | reObj = ranMat; 618 | } 619 | return reObj; 620 | }, 621 | storeData:function (curr,next) { 622 | next = next || {}; 623 | var that = this, opts = that.$opts,multi = opts.multiPane,valCell = that.valCell, 624 | days = new Date().getDate(), DTS = that.$data,isnext = jet.isObj(next), 625 | RES = {yearlist:[],monthlist:[[],[]],daylist:[],daytit:[],timelist:[]},seltime, 626 | cday = curr.DD == null ? days : curr.DD, nday = next.DD == null ? days : next.DD, 627 | timeA = {hh:curr.hh,mm:curr.mm,ss:curr.ss}, timeB = {hh:next.hh||0,mm:next.mm||0,ss:next.ss||0}; 628 | //设置年的数据 629 | RES.yearlist.push(that.eachYear(parseInt(curr.YYYY),1)); 630 | if(multi == false){ 631 | var yearNext = isnext ? next.YYYY : curr.YYYY; 632 | RES.yearlist.push(that.eachYear(parseInt(yearNext),2)); 633 | } 634 | //设置月的数据 635 | RES.monthlist[0] = that.eachMonth(curr.YYYY,0); 636 | if(multi == false){ 637 | var monthNext = isnext ? next.YYYY : curr.YYYY+1; 638 | RES.monthlist[1] = that.eachMonth(curr.YYYY+1,1); 639 | } 640 | //设置天的数据 641 | RES.daylist.push(that.eachDays(curr.YYYY,curr.MM,cday,0)); 642 | RES.daytit.push({YYYY:curr.YYYY,MM:curr.MM}); 643 | if(multi == false){ 644 | var dayNext = jet.nextMonth(curr.YYYY,curr.MM); 645 | RES.daylist.push(that.eachDays(dayNext.y,dayNext.m,nday,1)); 646 | RES.daytit.push({YYYY:dayNext.y,MM:dayNext.m}); 647 | } 648 | //设置时间数据 649 | that.selectTime = [timeA,timeB]; 650 | RES.timelist.push(that.eachTime(timeA,1)); 651 | if(multi == false){ 652 | seltime = that.dlen == 7 && opts.range && !isnext ? timeA : timeB; 653 | if(that.dlen == 7 && opts.range && jet.valText(valCell) == ""){ 654 | that.selectTime[1] = jet.extend(timeB,timeA); 655 | } 656 | RES.timelist.push(that.eachTime(seltime,2)); 657 | } 658 | //最后将数据合并于总数据中 659 | jet.extend(that.$data,RES); 660 | }, 661 | dateTemplate : function() { 662 | var that = this, opts = that.$opts, multi = opts.multiPane,YMDStr = "",hmsStr = "",lang = opts.language, 663 | ytxt = lang.name == "cn" ? "年":"", mtxt = lang.name == "cn" ? "月":""; 664 | var ymvals = multi ? '{%=ymlist[0].YYYY%}-{%=ymlist[0].MM%}':'{%=ymlist[0].YYYY%}-{%=ymlist[0].MM%}#{%=ymlist[ynidx].YYYY%}-{%=ymlist[ynidx].MM%}'; 665 | var aowArr = (function () { 666 | var butArr = [], ismu = multi ? "11":"23"; 667 | if(that.dlen == 1){ 668 | butArr = ['{%=yearlist[i][0].y-'+ismu+'%}','{%=yearlist[i][yearlist[i].length-1].y%}']; 669 | }else if(that.dlen == 2){ 670 | butArr = multi ? ['{%=yearlist[0][0].y-1%}','{%=yearlist[0][0].y+1%}']:['{%=yearlist[i][0].y-'+ismu+'%}','{%=yearlist[i][yearlist[i].length-1].y%}']; 671 | }else if(that.dlen>2 && that.dlen <=6){ 672 | butArr = ['{%=yearlist[0][0].y-1%}','{%=yearlist[0][0].y+1%}']; 673 | } 674 | return butArr; 675 | })(); 676 | var lyPrev = '', 677 | lyNext = '', 678 | ryPrev = '', 679 | ryNext = '', 680 | mPrev = '{% if(dlen>2){ %}{% } %}', 681 | mNext = '{% if(dlen>2){ %}{% } %}'; 682 | //循环年的模板 683 | var yaerHtml = '| {%=yearlist[i][y].y%}'+ytxt+' | {% if((y+1)%3==0){ %}
| {%=monthlist[i][m].m%}'+mtxt+' | {% if((m+1)%3==0){ %}
| {%=daylist[i][d].day%} | {% if((d+1)%7==0){ %}
{%=lang.times[0]%}
{%=lang.times[1]%}
{%=lang.times[2]%}
' + d + '' + lunartext + '
'; 1126 | }else{ 1127 | festivalStr = '' + d + '
'; 1128 | } 1129 | return festivalStr; 1130 | }; 1131 | //判断是否在限制的日期之中 1132 | var dateLimit = function(Y, M, D, isMonth){ 1133 | var thatNum = parseInt(Y + "" + jet.digit(M) + "" + jet.digit(D)); 1134 | if(isMonth){ 1135 | if (thatNum >= minNum && thatNum <= maxNum) return true; 1136 | }else { 1137 | if (minNum > thatNum || maxNum < thatNum) return true; 1138 | } 1139 | }; 1140 | 1141 | var regExpDate = function (date,cls) { 1142 | var inArray = function (search,array){ 1143 | for(var i in array) if(array[i]==search) return true; 1144 | return false; 1145 | }; 1146 | if(endval.length > 0 && endval[0]!=""){ 1147 | if(/\%/g.test(endval[0])){ 1148 | var reval = endval[0].replace(/\%/g,"").split(","), enArr = []; 1149 | jet.each(reval,function (r,rel) { 1150 | enArr.push(jet.digit(parseInt(rel))); 1151 | }); 1152 | var isfind = inArray(jet.digit(date), enArr) == false; 1153 | cls = jet.isBool(endval[1]) ? (isfind ? " disabled" :cls) : (isfind ? cls :" disabled"); 1154 | }else { 1155 | var valreg = that.dateRegExp(endval[0]), regday = valreg.test(jet.digit(date)); 1156 | cls = jet.isBool(endval[1]) ? (regday ? " disabled" : cls) : (regday ? cls : " disabled"); 1157 | } 1158 | } 1159 | return cls; 1160 | }; 1161 | 1162 | //var ymds = ymdarr[1] 1163 | //上一月剩余天数 1164 | for (var p = prevDaysNum - firstWeek + 1; p <= prevDaysNum; p++, count++) { 1165 | var pmark = setMark(prevM.y,prevM.m,p), pcls = dateLimit(prevM.y, prevM.m, p, false) ? "disabled" : "other"; 1166 | pcls = regExpDate(p,pcls); 1167 | daysArr.push({style:pcls,ymd:prevM.y+'-'+jet.digit(prevM.m)+'-'+jet.digit(p),day:(isfestival(prevM.y,prevM.m,p) + pmark)}); 1168 | } 1169 | //本月的天数 1170 | for(var b = 1; b <= daysNum; b++, count++){ 1171 | var bmark = setMark(yd,md,b), bcls = ""; 1172 | var dateval = parseInt(yd+""+jet.digit(md)+""+jet.digit(b)), 1173 | parsdate = dateval > startDate, rangdate = dateval < endDate; 1174 | if(dateLimit(yd, md, b, true)){ 1175 | if(dateval == startDate || dateval == endDate){ 1176 | bcls = " action"; 1177 | }else if(parsdate&&rangdate){ 1178 | bcls = " contain"; 1179 | }else { 1180 | bcls = ""; 1181 | } 1182 | }else { 1183 | bcls = " disabled"; 1184 | } 1185 | bcls = regExpDate(b,bcls); 1186 | daysArr.push({style:"normal"+bcls,ymd:yd+'-'+jet.digit(md)+'-'+jet.digit(b),day:(isfestival(yd,md,b) + bmark)}); 1187 | } 1188 | //下一月开始天数 1189 | for(var n = 1, nlen = 42 - count; n <= nlen; n++){ 1190 | var nmark = setMark(nextM.y,nextM.m,n); 1191 | var ncls = dateLimit(nextM.y, nextM.m, n, false) ? "disabled" : "other"; 1192 | ncls = regExpDate(n,ncls); 1193 | daysArr.push({style:ncls,ymd:nextM.y+'-'+jet.digit(nextM.m)+'-'+jet.digit(n),day:(isfestival(nextM.y,nextM.m,n) + nmark)}); 1194 | } 1195 | //将星期与日期拼接起来 1196 | return daysArr; 1197 | }, 1198 | eachTime : function (hmsArr,type) { 1199 | var that = this,opts = that.$opts, range = opts.range,multi = opts.multiPane, minVal = [], maxVal = [], 1200 | mhms = ["hh","mm","ss"], timeArr = [],hmsCls = '',format = that.format, 1201 | ntVal = jet.trim(that.minDate).replace(/\s+/g," "), 1202 | xtVal = jet.trim(that.maxDate).replace(/\s+/g," "), 1203 | nVal = ntVal.split(" "), xVal = xtVal.split(" "); 1204 | if(that.dlen>3 && /\:/.test(nVal) && /\:/.test(xVal)){ 1205 | minVal = jet.reMatch(/\s/.test(ntVal)&&that.dlen>3 ? nVal[1] : ntVal); 1206 | maxVal = jet.reMatch(/\s/.test(xtVal)&&that.dlen>3 ? xVal[1] : xtVal); 1207 | } 1208 | jet.each([24,60,60],function (s,lens) { 1209 | timeArr[s] = []; 1210 | var unhmsVal = minVal[s] == undefined || minVal[s] == 0 ? hmsArr[mhms[s]] : minVal[s], 1211 | currVal = that.getValue() == "" ? unhmsVal : hmsArr[mhms[s]]; 1212 | if(that.dlen>3 && /\:/.test(nVal) && type==1){ 1213 | that.selectTime[0][mhms[s]] = currVal; 1214 | } 1215 | for (var h = 0; h < lens; h++) { 1216 | var exists = new RegExp(mhms[s],"g").test(format); 1217 | if(h == currVal){ 1218 | hmsCls = exists ? "action" : "disabled"; 1219 | }else if(!exists || !range && multi &&(h' + lunar.solarYear + '\u5E74' + lunar.solarMonth + '\u6708' + lunar.solarDate + '\u65E5 ' + lunar.inWeekDays + '
\u519C\u5386:' + lunar.shengxiao + '\u5E74 ' + lunar.lnongMonth + '\u6708' + lunar.lnongDate + '
' + lunar.ganzhiYear + '\u5E74 ' + lunar.ganzhiMonth + '\u6708 ' + lunar.ganzhiDate + '\u65E5
'; 1285 | var Fesjieri = (lunar.solarFestival || lunar.lunarFestival) != "" ? '' + ("\u8282\u65E5:"+lunar.solarFestival + lunar.lunarFestival) + '
' : ""; 1286 | var Fesjieqi = lunar.jieqi != "" ? ''+(lunar.jieqi != "" ? "\u8282\u6C14:"+lunar.jieqi : "") + '
': ""; 1287 | var tiptext = (lunar.solarFestival || lunar.lunarFestival || lunar.jieqi) != "" ? (Fesjieri + Fesjieqi) : ""; 1288 | jet.html(tipDiv,tiphtml + tiptext); 1289 | document.body.appendChild(tipDiv); 1290 | //获取并设置农历提示框出现的位置 1291 | var tipPos = that.lunarOrien(tipDiv, this); 1292 | jet.setCss(tipDiv,{"zIndex": (opts.zIndex == undefined ? 10000 + 5 : opts.zIndex + 5),top:tipPos.top,left:tipPos.left,position:"absolute",display:"block"}); 1293 | }); 1294 | //鼠标移除提示框消失 1295 | jet.on(node,"mouseout",function () { 1296 | document.body.removeChild($Q("#jedatetipscon")); 1297 | }); 1298 | }); 1299 | if (that.dateCell.nodeType === 1 && !jet.hasClass(that.dateCell,"grid")) that.dateCell.className = that.dateCell.className + " grid"; 1300 | }, 1301 | //农历方位辨别 1302 | lunarOrien : function(obj, self, pos) { 1303 | var tops, leris, ortop, orleri, rect =self.getBoundingClientRect(), boxW = obj.offsetWidth, boxH = obj.offsetHeight; 1304 | leris = rect.right + boxW / 1.5 >= jet.docArea(true) ? rect.right - boxW : rect.left + (pos ? 0 : jet.docScroll(true)); 1305 | tops = rect.bottom + boxH / 1 <= jet.docArea() ? rect.bottom - 1 : rect.top > boxH / 1.5 ? rect.top - boxH - 1 : jet.docArea() - boxH; 1306 | if(leris + boxW > jet.docArea(true)) leris = rect.left - (boxW - rect.width); 1307 | ortop = Math.max(tops + (pos ? 0 :jet.docScroll()) + 1, 1) + "px", orleri = leris + "px"; 1308 | return {top: ortop, left: orleri } 1309 | }, 1310 | //辨别控件的方位 1311 | dateOrien : function(elbox, valCls, pos) { 1312 | var that = this, tops, leris, ortop, orleri, 1313 | rect = that.$opts.fixed ? valCls.getBoundingClientRect() : elbox.getBoundingClientRect(), 1314 | leris = rect.left, tops = rect.bottom; 1315 | if(that.$opts.fixed) { 1316 | var boxW = elbox.offsetWidth, boxH = elbox.offsetHeight; 1317 | //如果右侧超出边界 1318 | if(leris + boxW > jet.docArea(true)){ 1319 | leris = leris - (boxW - rect.width); 1320 | } 1321 | //如果底部超出边界 1322 | if(tops + boxH > jet.docArea()){ 1323 | tops = rect.top > boxH ? rect.top - boxH -2 : jet.docArea() - boxH -1; 1324 | } 1325 | //根据目标元素计算弹层位置 1326 | ortop = Math.max(tops + (pos ? 0 :jet.docScroll())+1, 1) + "px"; orleri = leris + "px"; 1327 | }else{ 1328 | //弹层位置位于页面上下左右居中 1329 | ortop = "50%"; orleri = "50%"; 1330 | elbox.style.cssText = "marginTop:"+-(rect.height / 2)+";marginLeft:"+-(rect.width / 2); 1331 | } 1332 | jet.setCss(elbox,{top:ortop,left:orleri}); 1333 | }, 1334 | tips : function (text, time) { 1335 | var that = this, tipCls = $Q(".jedate-tips",that.dateCell),tipTime; 1336 | jet.html(tipCls,text||""); jet.setCss(tipCls,{display:"block"}); 1337 | clearTimeout(tipTime); 1338 | tipTime = setTimeout(function(){ 1339 | jet.html(tipCls,""); jet.setCss(tipCls,{display:"none"}); 1340 | }, (time||2.5)*1000); 1341 | }, 1342 | locateScroll : function () { 1343 | var that = this, ulCell = $Q(".jedate-time",that.dateCell).querySelectorAll("ul"); 1344 | jet.each(ulCell, function(i,cell) { 1345 | var hmsCls = cell.querySelector(".action"); 1346 | cell.scrollTop = hmsCls ? (hmsCls.offsetTop-145):0; 1347 | }); 1348 | if(that.dlen != 7) jet.setCss($Q(".jedate-time",that.dateCell),{display:'none'}); 1349 | } 1350 | }); 1351 | 1352 | //农历数据 1353 | function jeLunar(ly,lm,ld) { 1354 | var lunarInfo=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448], 1355 | sTermInfo = [ 0, 21208, 43467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758 ]; 1356 | var Gan = "甲乙丙丁戊己庚辛壬癸", Zhi = "子丑寅卯辰巳午未申酉戌亥", Animals = "鼠牛虎兔龙蛇马羊猴鸡狗猪"; 1357 | var solarTerm = [ "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", 1358 | "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至" ]; 1359 | var nStr1 = "日一二三四五六七八九十", nStr2 = "初十廿卅", nStr3 = [ "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"], 1360 | sFtv1 = { 1361 | "0101" : "*1元旦节", "0202" : "湿地日", 1362 | "0214" : "情人节", "0308" : "妇女节", 1363 | "0312" : "植树节", "0315" : "消费者权益日", 1364 | "0401" : "愚人节", "0422" : "地球日", 1365 | "0501" : "*1劳动节", "0504" : "青年节", 1366 | "0512" : "护士节", "0518" : "博物馆日", 1367 | "0520" : "母亲节", "0601" : "儿童节", 1368 | "0623" : "奥林匹克日", "0630" : "父亲节", 1369 | "0701" : "建党节", "0801" : "建军节", 1370 | "0903" : "抗战胜利日", "0910" : "教师节", 1371 | "1001" : "*3国庆节", "1201" : "艾滋病日", 1372 | "1224" : "平安夜", "1225" : "圣诞节" 1373 | }, 1374 | sFtv2 = { 1375 | "0100" : "除夕", "0101" : "*2春节", 1376 | "0115" : "元宵节", "0505" : "*1端午节", 1377 | "0707" : "七夕节", "0715" : "中元节", 1378 | "0815" : "*1中秋节", "0909" : "*1重阳节", 1379 | "1015" : "下元节", "1208" : "腊八节", 1380 | "1223" : "小年" 1381 | 1382 | }; 1383 | function flunar(Y) { 1384 | var sTerm = function (j, i) { 1385 | var h = new Date((31556925974.7 * (j - 1900) + sTermInfo[i] * 60000) + Date.UTC(1900, 0, 6, 2, 5)); 1386 | return (h.getUTCDate()); 1387 | }, 1388 | d = function (k) { 1389 | var h, j = 348; 1390 | for (h = 32768; h > 8; h >>= 1) j += (lunarInfo[k - 1900] & h) ? 1 : 0; 1391 | return (j + b(k)); 1392 | }, 1393 | ymdCyl = function (h) { 1394 | return (Gan.charAt(h % 10) + Zhi.charAt(h % 12)); 1395 | }, 1396 | b = function (h) { 1397 | var islp = (g(h)) ? ((lunarInfo[h - 1900] & 65536) ? 30 : 29) : (0); 1398 | return islp; 1399 | }, 1400 | g = function (h) { 1401 | return (lunarInfo[h - 1900] & 15) 1402 | }, 1403 | e = function (i, h) { 1404 | return ((lunarInfo[i - 1900] & (65536 >> h)) ? 30 : 29); 1405 | }, 1406 | newymd = function (m) { 1407 | var k, j = 0, h = 0, l = new Date(1900, 0, 31), n = (m - l) / 86400000; 1408 | this.dayCyl = n + 40; 1409 | this.monCyl = 14; 1410 | for (k = 1900; k < 2050 && n > 0; k++) { 1411 | h = d(k); n -= h; 1412 | this.monCyl += 12; 1413 | } 1414 | if (n < 0) { 1415 | n += h; k--; 1416 | this.monCyl -= 12; 1417 | } 1418 | this.year = k; 1419 | this.yearCyl = k - 1864; 1420 | j = g(k); 1421 | this.isLeap = false; 1422 | for (k = 1; k < 13 && n > 0; k++) { 1423 | if (j > 0 && k == (j + 1) && this.isLeap == false) { 1424 | --k; 1425 | this.isLeap = true; 1426 | h = b(this.year); 1427 | } else { 1428 | h = e(this.year, k); 1429 | } 1430 | if (this.isLeap == true && k == (j + 1)) { 1431 | this.isLeap = false; 1432 | } 1433 | n -= h; 1434 | if (this.isLeap == false) this.monCyl++; 1435 | } 1436 | if (n == 0 && j > 0 && k == j + 1) { 1437 | if (this.isLeap) { 1438 | this.isLeap = false; 1439 | } else { 1440 | this.isLeap = true; 1441 | --k; 1442 | --this.monCyl; 1443 | } 1444 | } 1445 | if (n < 0) { 1446 | n += h; --k; 1447 | --this.monCyl; 1448 | } 1449 | this.month = k; 1450 | this.day = n + 1; 1451 | }, 1452 | digit = function (num) { 1453 | return num < 10 ? "0" + (num | 0) : num; 1454 | }, 1455 | reymd = function (i, j) { 1456 | var h = i; 1457 | return j.replace(/dd?d?d?|MM?M?M?|yy?y?y?/g, function (k) { 1458 | switch (k) { 1459 | case "yyyy": 1460 | var l = "000" + h.getFullYear(); 1461 | return l.substring(l.length - 4); 1462 | case "dd": return digit(h.getDate()); 1463 | case "d": return h.getDate().toString(); 1464 | case "MM": return digit((h.getMonth() + 1)); 1465 | case "M": return h.getMonth() + 1; 1466 | } 1467 | }); 1468 | }, 1469 | lunarMD = function (i, h) { 1470 | var j; 1471 | switch (i, h) { 1472 | case 10: j = "初十"; break; 1473 | case 20: j = "二十"; break; 1474 | case 30: j = "三十"; break; 1475 | default: 1476 | j = nStr2.charAt(Math.floor(h / 10)); 1477 | j += nStr1.charAt(h % 10); 1478 | } 1479 | return j; 1480 | }; 1481 | this.isToday = false; 1482 | this.isRestDay = false; 1483 | this.solarYear = reymd(Y, "yyyy"); 1484 | this.solarMonth = reymd(Y, "M"); 1485 | this.solarDate = reymd(Y, "d"); 1486 | this.solarWeekDay = Y.getDay(); 1487 | this.inWeekDays = "星期" + nStr1.charAt(this.solarWeekDay); 1488 | var X = new newymd(Y); 1489 | this.lunarYear = X.year; 1490 | this.shengxiao = Animals.charAt((this.lunarYear - 4) % 12); 1491 | this.lunarMonth = X.month; 1492 | this.lunarIsLeapMonth = X.isLeap; 1493 | this.lnongMonth = this.lunarIsLeapMonth ? "闰" + nStr3[X.month - 1] : nStr3[X.month - 1]; 1494 | this.lunarDate = X.day; 1495 | this.showInLunar = this.lnongDate = lunarMD(this.lunarMonth, this.lunarDate); 1496 | if (this.lunarDate == 1) { 1497 | this.showInLunar = this.lnongMonth + "月"; 1498 | } 1499 | this.ganzhiYear = ymdCyl(X.yearCyl); 1500 | this.ganzhiMonth = ymdCyl(X.monCyl); 1501 | this.ganzhiDate = ymdCyl(X.dayCyl++); 1502 | this.jieqi = ""; 1503 | this.restDays = 0; 1504 | if (sTerm(this.solarYear, (this.solarMonth - 1) * 2) == reymd(Y, "d")) { 1505 | this.showInLunar = this.jieqi = solarTerm[(this.solarMonth - 1) * 2]; 1506 | } 1507 | if (sTerm(this.solarYear, (this.solarMonth - 1) * 2 + 1) == reymd(Y, "d")) { 1508 | this.showInLunar = this.jieqi = solarTerm[(this.solarMonth - 1) * 2 + 1]; 1509 | } 1510 | if (this.showInLunar == "清明") { 1511 | this.showInLunar = "清明节"; 1512 | this.restDays = 1; 1513 | } 1514 | this.solarFestival = sFtv1[reymd(Y, "MM") + reymd(Y, "dd")]; 1515 | if (typeof this.solarFestival == "undefined") { 1516 | this.solarFestival = ""; 1517 | } else { 1518 | if (/\*(\d)/.test(this.solarFestival)) { 1519 | this.restDays = parseInt(RegExp.$1); 1520 | this.solarFestival = this.solarFestival.replace(/\*\d/, ""); 1521 | } 1522 | } 1523 | this.showInLunar = (this.solarFestival == "") ? this.showInLunar : this.solarFestival; 1524 | this.lunarFestival = sFtv2[this.lunarIsLeapMonth ? "00" : digit(this.lunarMonth) + digit(this.lunarDate)]; 1525 | if (typeof this.lunarFestival == "undefined") { 1526 | this.lunarFestival = ""; 1527 | } else { 1528 | if (/\*(\d)/.test(this.lunarFestival)) { 1529 | this.restDays = (this.restDays > parseInt(RegExp.$1)) ? this.restDays : parseInt(RegExp.$1); 1530 | this.lunarFestival = this.lunarFestival.replace(/\*\d/, ""); 1531 | } 1532 | } 1533 | if (this.lunarMonth == 12 && this.lunarDate == e(this.lunarYear, 12)) { 1534 | this.lunarFestival = sFtv2["0100"]; 1535 | this.restDays = 1; 1536 | } 1537 | this.showInLunar = (this.lunarFestival == "") ? this.showInLunar : this.lunarFestival; 1538 | } 1539 | return new flunar(new Date(ly, lm, ld)); 1540 | } 1541 | return jeDate; 1542 | }); 1543 | --------------------------------------------------------------------------------