-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatetimeShift.js
125 lines (118 loc) · 3.06 KB
/
datetimeShift.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* datetimeShift,js
* Y-m-d H:i:s or Y-m-d H:i
* author:Yoda
*/
;(function($) {
$.datetimeShift = function($so, $eo, settingOption){
function ro($s, $e){
// 開始時間事件
$s.datetimepicker({
format : settingOption.getFormatPatten(),
onShow : function(ct) {
if($e != null){
var endTime = $e.val().split(" ");
var maxDate = endTime[0].replace(/\-/g, '/');
var maxTime = endTime[1];
this.setOptions({
maxDate : maxDate ? maxDate : false,
//maxTime : maxTime ? maxTime : false
});
}
},
lang : 'ch',
step : settingOption.step,
timepicker: settingOption.showTimepicker(),
datepicker: settingOption.showDatepicker()
});
$s.val(DateUtil.shift($s, settingOption));
if($e != null){
// 結束時間事件
$e.datetimepicker({
format : settingOption.getFormatPatten(),
onShow : function(ct) {
var startTime = $s.val().split(" ");
var minDate = startTime[0].replace(/\-/g, '/');
var minTime = startTime[1];
this.setOptions({
minDate : minDate ? minDate : false,
//minTime : minTime ? minTime : false,
});
},
lang : 'ch',
step : settingOption.step,
timepicker: settingOption.showTimepicker(),
datepicker: settingOption.showDatepicker()
});
}
$e.val(DateUtil.dateToStrSet(new Date(), settingOption.ymdSign, settingOption.hnsSign, settingOption.format));
/**
* 位移-年
*/
this.yearShift = function(offsetnum) {
settingOption.num = offsetnum;
settingOption.type = DateShiftSetting.getYear();
if($s != null){
$s.val(DateUtil.shift($s, settingOption));
}
if($e != null){
$e.val(DateUtil.shift($e, settingOption));
}
}
/**
* 位移-月
*/
this.monthShift = function(offsetnum) {
settingOption.num = offsetnum;
settingOption.type = DateShiftSetting.getMonth();
if($s != null){
$s.val(DateUtil.shift($s, settingOption));
}
if($e != null){
$e.val(DateUtil.shift($e, settingOption));
}
}
/**
* 位移-日
*/
this.dayShift = function(offsetnum) {
console.log("WwW"+offsetnum);
settingOption.num = offsetnum;
settingOption.type = DateShiftSetting.getDay();
if($s != null){
$s.val(DateUtil.shift($s, settingOption));
}
if($e != null){
$e.val(DateUtil.shift($e, settingOption));
}
}
/**
* 位移-時
*/
this.hourShift = function(offsetnum) {
settingOption.num = offsetnum;
settingOption.type = DateShiftSetting.getHour();
if($s != null){
$s.val(DateUtil.shift($s, settingOption));
}
if($e != null){
$e.val(DateUtil.shift($e, settingOption));
}
}
/**
* 位移-分
*/
this.minShift = function(offsetnum) {
settingOption.num = offsetnum;
settingOption.type = DateShiftSetting.getMinute();
if($s != null){
$s.val(DateUtil.shift($s, settingOption));
}
if($e != null){
$e.val(DateUtil.shift($e, settingOption));
}
}
}
return new ro($so, $eo);
}
})(jQuery);