Skip to content

Commit d01d8d7

Browse files
committed
增加addHours函数以及测试用例;
1 parent 2fd8d65 commit d01d8d7

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

YanZhiwei.JavaScript.Utilities/jqUtilsDemo.aspx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
$.getJSON("BackHandler/QueryHandler.ashx?action=queryperson", function (data) {
1313
var table = document.createElement('table');
1414
table.id = "jsonTable";
15-
table.style = "border-collapse: collapse;";
16-
table.border = "1";
17-
table.cellPadding = "5";
15+
//table.style = "border-collapse: collapse;";
16+
//table.border = "1";
17+
//table.cellPadding = "5";
1818
$('#container').append(table);
1919
// document.body.appendChild(table);
2020
jqUtils.UITable.createTable('jsonTable', data);
2121
});
2222
$.getJSON("BackHandler/QueryHandler.ashx?action=queryperson", function (data) {
2323
var table = document.createElement('table');
2424
table.id = "jsonTable2";
25-
table.style = "border-collapse: collapse;";
26-
table.border = "1";
27-
table.cellPadding = "5";
25+
//table.style = "border-collapse: collapse;";
26+
//table.border = "1";
27+
//table.cellPadding = "5";
2828
$('#container').append(table);
2929
// document.body.appendChild(table);
3030
jqUtils.UITable.createTable('jsonTable2', data);

YanZhiwei.JavaScript.Utilities/jsUtils.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\
384384
document.body.appendChild(script);
385385
}
386386
};
387-
js.check = {
387+
jsUtils.check = {
388388
isIP: function (strIP) {
389389
/// <summary>
390390
/// 是否是IP地址
@@ -566,7 +566,7 @@ whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\
566566
return false;
567567
}
568568
};
569-
js.mobile = {
569+
jsUtils.mobile = {
570570
isMobile: function () {
571571
/// <summary>
572572
/// 判断是否移动设备
@@ -849,6 +849,17 @@ whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\
849849
var _newDate = new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
850850
return this.formart(_newDate, format);
851851
},
852+
addHours: function (date, hour, format) {
853+
/// <summary>
854+
/// 增加小时
855+
/// <para>eg:jsUtils.datetime.addHours(new Date(), 2);</para>
856+
/// </summary>
857+
/// <param name="date">目标日期</param>
858+
/// <param name="days">增加天数</param>
859+
/// <param name="format">格式</param>
860+
var _newDate = new Date(date.getTime() + hour * 60 * 60 * 1000);
861+
return this.formart(_newDate, format);
862+
},
852863
getFriendlyString: function (time) {
853864
/// <summary>
854865
/// 获取时间差友好提示

YanZhiwei.JavaScript.Utilities/jsUtilsTest.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,22 @@
100100
var _array = _dic.order("4", false);
101101

102102
}
103+
function addHoursTest() {
104+
105+
alert(jsUtils.datetime.addHours(new Date(), 2));
106+
107+
}
103108
</script>
104109
</head>
105110
<body>
106111
<input id="Button1" type="button" value="delegate" onclick="delegate()" />
107112
<input id="Button2" type="button" value="urlget" onclick="urlget()" />
108113
<input id="Button3" type="button" value="is" onclick="isTest()" />
109114
<input id="Button4" type="button" value="Uri" onclick="UriTest()" />
110-
<input id="Button4" type="button" value="JsonSerialize" onclick="jsonSerializeTest()" />
111-
<input id="Button5" type="button" value="DictionaryToArray" onclick="dictionaryToArrayTest()" />
112-
<input id="Button6" type="button" value="DictionaryforInTest" onclick="dictionaryforInTest()" />
115+
<input id="Button5" type="button" value="JsonSerialize" onclick="jsonSerializeTest()" />
116+
<input id="Button6" type="button" value="DictionaryToArray" onclick="dictionaryToArrayTest()" />
117+
<input id="Button7" type="button" value="DictionaryforInTest" onclick="dictionaryforInTest()" />
118+
<input id="Button8" type="button" value="addHoursTest" onclick="addHoursTest()" />
113119
<!--<input id="Button7" type="button" value="DictionaryOrderTest" onclick="dictionaryOrderTest()" />-->
114120
</body>
115121
</html>

0 commit comments

Comments
 (0)