代码
1
<
html
>
2 < head >
3 < title > my97 test </ title >
4 < script type ="text/javascript" src ="My97DatePicker/WdatePicker.js" ></ script >
5 < script type ="text/javascript" >
6 // 日期格式化函数
7 Date.prototype.format = function (mask) {
8 var d = this ;
9 var zeroize = function (value, length) {
10 if ( ! length) length = 2 ;
11 value = String(value);
12 for ( var i = 0 , zeros = '' ; i < (length - value.length); i ++ ) {
13 zeros += ' 0 ' ;
14 }
15 return zeros + value;
16 };
17
18 return mask.replace( / "[^"]*"|'[^']*'|\b(?:d{1,4}|m{1,4}|yy(?:yy)?|([hHMstT])\1?|[lLZ])\b / g, function ($ 0 ) {
19 switch ($ 0 ) {
20 case ' d ' : return d.getDate();
21 case ' dd ' : return zeroize(d.getDate());
22 case ' ddd ' : return [ ' Sun ' , ' Mon ' , ' Tue ' , ' Wed ' , ' Thr ' , ' Fri ' , ' Sat ' ][d.getDay()];
23 case ' dddd ' : return [ ' Sunday ' , ' Monday ' , ' Tuesday ' , ' Wednesday ' , ' Thursday ' , ' Friday ' , ' Saturday ' ][d.getDay()];
24 case ' M ' : return d.getMonth() + 1 ;
25 case ' MM ' : return zeroize(d.getMonth() + 1 );
26 case ' MMM ' : return [ ' Jan ' , ' Feb ' , ' Mar ' , ' Apr ' , ' May ' , ' Jun ' , ' Jul ' , ' Aug ' , ' Sep ' , ' Oct ' , ' Nov ' , ' Dec ' ][d.getMonth()];
27 case ' MMMM ' : return [ ' January ' , ' February ' , ' March ' , ' April ' , ' May ' , ' June ' , ' July ' , ' August ' , ' September ' , ' October ' , ' November ' , ' December ' ][d.getMonth()];
28 case ' yy ' : return String(d.getFullYear()).substr( 2 );
29 case ' yyyy ' : return d.getFullYear();
30 case ' h ' : return d.getHours() % 12 || 12 ;
31 case ' hh ' : return zeroize(d.getHours() % 12 || 12 );
32 case ' H ' : return d.getHours();
33 case ' HH ' : return zeroize(d.getHours());
34 case ' m ' : return d.getMinutes();
35 case ' mm ' : return zeroize(d.getMinutes());
36 case ' s ' : return d.getSeconds();
37 case ' ss ' : return zeroize(d.getSeconds());
38 case ' l ' : return zeroize(d.getMilliseconds(), 3 );
39 case ' L ' : var m = d.getMilliseconds();
40 if (m > 99 ) m = Math.round(m / 10 );
41 return zeroize(m);
42 case ' tt ' : return d.getHours() < 12 ? ' am ' : ' pm ' ;
43 case ' TT ' : return d.getHours() < 12 ? ' AM ' : ' PM ' ;
44 case ' Z ' : return d.toUTCString().match( / [A-Z]+$ / );
45 // Return quoted strings with the surrounding quotes removed
46 default : return $ 0 .substr( 1 , $ 0 .length - 2 );
47 }
48 });
49 };
50 // 设置结束日期为起始日期加指定天数
51 function SetEndDate(objEnddate, days)
52 {
53 var dt = new Date(parseInt($dp.cal.getP( ' y ' )), parseInt($dp.cal.getP( ' M ' )) - 1 , parseInt($dp.cal.getP( ' d ' )) + days);
54 objEnddate.value = dt.format( " yyyy/MM/dd " );
55 }
56 </ script >
57 </ head >
58 < body >
59 < span style ="width:100px;" > Start Date: </ span >< input type ="text" id ="date1" width ="120px" readonly ="true" onfocus ="WdatePicker({dateFmt:'yyyy/MM/dd',onpicked:function(dp){SetEndDate($dp.$('date2'), 14);}});" />< br />
60 < span style ="width:100px;" > End Date: </ span >< input type ="text" id ="date2" width ="120px" readonly ="true" onfocus ="WdatePicker({dateFmt:'yyyy/MM/dd'});" />
61 </ body >
62 </ html >
2 < head >
3 < title > my97 test </ title >
4 < script type ="text/javascript" src ="My97DatePicker/WdatePicker.js" ></ script >
5 < script type ="text/javascript" >
6 // 日期格式化函数
7 Date.prototype.format = function (mask) {
8 var d = this ;
9 var zeroize = function (value, length) {
10 if ( ! length) length = 2 ;
11 value = String(value);
12 for ( var i = 0 , zeros = '' ; i < (length - value.length); i ++ ) {
13 zeros += ' 0 ' ;
14 }
15 return zeros + value;
16 };
17
18 return mask.replace( / "[^"]*"|'[^']*'|\b(?:d{1,4}|m{1,4}|yy(?:yy)?|([hHMstT])\1?|[lLZ])\b / g, function ($ 0 ) {
19 switch ($ 0 ) {
20 case ' d ' : return d.getDate();
21 case ' dd ' : return zeroize(d.getDate());
22 case ' ddd ' : return [ ' Sun ' , ' Mon ' , ' Tue ' , ' Wed ' , ' Thr ' , ' Fri ' , ' Sat ' ][d.getDay()];
23 case ' dddd ' : return [ ' Sunday ' , ' Monday ' , ' Tuesday ' , ' Wednesday ' , ' Thursday ' , ' Friday ' , ' Saturday ' ][d.getDay()];
24 case ' M ' : return d.getMonth() + 1 ;
25 case ' MM ' : return zeroize(d.getMonth() + 1 );
26 case ' MMM ' : return [ ' Jan ' , ' Feb ' , ' Mar ' , ' Apr ' , ' May ' , ' Jun ' , ' Jul ' , ' Aug ' , ' Sep ' , ' Oct ' , ' Nov ' , ' Dec ' ][d.getMonth()];
27 case ' MMMM ' : return [ ' January ' , ' February ' , ' March ' , ' April ' , ' May ' , ' June ' , ' July ' , ' August ' , ' September ' , ' October ' , ' November ' , ' December ' ][d.getMonth()];
28 case ' yy ' : return String(d.getFullYear()).substr( 2 );
29 case ' yyyy ' : return d.getFullYear();
30 case ' h ' : return d.getHours() % 12 || 12 ;
31 case ' hh ' : return zeroize(d.getHours() % 12 || 12 );
32 case ' H ' : return d.getHours();
33 case ' HH ' : return zeroize(d.getHours());
34 case ' m ' : return d.getMinutes();
35 case ' mm ' : return zeroize(d.getMinutes());
36 case ' s ' : return d.getSeconds();
37 case ' ss ' : return zeroize(d.getSeconds());
38 case ' l ' : return zeroize(d.getMilliseconds(), 3 );
39 case ' L ' : var m = d.getMilliseconds();
40 if (m > 99 ) m = Math.round(m / 10 );
41 return zeroize(m);
42 case ' tt ' : return d.getHours() < 12 ? ' am ' : ' pm ' ;
43 case ' TT ' : return d.getHours() < 12 ? ' AM ' : ' PM ' ;
44 case ' Z ' : return d.toUTCString().match( / [A-Z]+$ / );
45 // Return quoted strings with the surrounding quotes removed
46 default : return $ 0 .substr( 1 , $ 0 .length - 2 );
47 }
48 });
49 };
50 // 设置结束日期为起始日期加指定天数
51 function SetEndDate(objEnddate, days)
52 {
53 var dt = new Date(parseInt($dp.cal.getP( ' y ' )), parseInt($dp.cal.getP( ' M ' )) - 1 , parseInt($dp.cal.getP( ' d ' )) + days);
54 objEnddate.value = dt.format( " yyyy/MM/dd " );
55 }
56 </ script >
57 </ head >
58 < body >
59 < span style ="width:100px;" > Start Date: </ span >< input type ="text" id ="date1" width ="120px" readonly ="true" onfocus ="WdatePicker({dateFmt:'yyyy/MM/dd',onpicked:function(dp){SetEndDate($dp.$('date2'), 14);}});" />< br />
60 < span style ="width:100px;" > End Date: </ span >< input type ="text" id ="date2" width ="120px" readonly ="true" onfocus ="WdatePicker({dateFmt:'yyyy/MM/dd'});" />
61 </ body >
62 </ html >