PageSourceSearch

https://allwork.co.kr/resources/assets/custom/js/dateUtils.js?v=1790900504841

js allwork.co.kr collected 2026-10-02 00:22:24 UTC 12,652 bytes, 313 lines download raw bytes

1/*
2 * 날짜 및 시간 처리.
3 */
4var dateUtils = {
5	setDatepicker : function (element) {
6		$(element).datepicker({
7			changeYear: true,  
8			changeMonth: true, 
9			//showButtonPanel: true, 
10			//currentText: '오늘 날짜', 
11			//closeText: '닫기', 
12			dayNames: ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'],
13			dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'], 
14			monthNamesShort: ['1','2','3','4','5','6','7','8','9','10','11','12'],
15			monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
16	  });
17		$(element).datepicker("option", "dateFormat", 'yy-mm-dd');
18	},
19	setDateMpicker : function (element) {
20		$(element).datepicker({
21			changeYear: true,
22			changeMonth: true, 
23			//showButtonPanel: true, 
24			//currentText: '오늘 날짜', 
25			//closeText: '닫기', 
26			dayNames: ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'],
27			dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'], 
28			monthNamesShort: ['1','2','3','4','5','6','7','8','9','10','11','12'],
29			monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
30	  });
31		$(element).datepicker("option", "dateFormat", 'yy-mm');
32	},
33
34	getDateStr : function (dateValue, splitter) {
35		if (!dateValue) return "";
36		var month = dateValue.getMonth() + 1 < 10 ? '0' + (dateValue.getMonth() + 1) : dateValue.getMonth() + 1;
37		//var day = dateValue.getDate() + 1 < 10 ? '0' + (dateValue.getDate() + 1) : dateValue.getDate() + 1;
38		var day = dateValue.getDate() < 10 ? ('0' + dateValue.getDate()) : dateValue.getDate();
39		return dateValue.getFullYear() + splitter + month + splitter + day;
40	},
41	
42	getHourStr : function (dateValue, splitter) {
43		if (!dateValue) return "";
44		var month = dateValue.getMonth() + 1 < 10 ? '0' + (dateValue.getMonth() + 1) : dateValue.getMonth() + 1;
45		//var day = dateValue.getDate() + 1 < 10 ? '0' + (dateValue.getDate() + 1) : dateValue.getDate() + 1;
46		var day = dateValue.getDate() < 10 ? ('0' + dateValue.getDate()) : dateValue.getDate();
47		var hour = dateValue.getHours() < 10 ? ('0' + dateValue.getHours()) : dateValue.getHours();
48		return "" + hour;
49	},
50	getDateHourStr : function (dateValue, splitter) {
51		if (!dateValue) return "";
52		var month = dateValue.getMonth() + 1 < 10 ? '0' + (dateValue.getMonth() + 1) : dateValue.getMonth() + 1;
53		//var day = dateValue.getDate() + 1 < 10 ? '0' + (dateValue.getDate() + 1) : dateValue.getDate() + 1;
54		var day = dateValue.getDate() < 10 ? ('0' + dateValue.getDate()) : dateValue.getDate();
55		var hour = dateValue.getHours() < 10 ? ('0' + dateValue.getHours()) : dateValue.getHours();
56		return dateValue.getFullYear() + splitter + month + splitter + day + " " + hour;
57	},
58	getMonthDateStr : function (dateValue, splitter) {
59		if (!dateValue) return "";
60		var month = dateValue.getMonth() + 1 < 10 ? '0' + (dateValue.getMonth() + 1) : dateValue.getMonth() + 1;
61		//var day = dateValue.getDate() + 1 < 10 ? '0' + (dateValue.getDate() + 1) : dateValue.getDate() + 1;
62		var day = dateValue.getDate() < 10 ? ('0' + dateValue.getDate()) : dateValue.getDate();
63		return month + splitter + day;
64	},
65	getYearMonthStr : function (dateValue, splitter) {
66		if (!dateValue) return "";
67		var month = dateValue.getMonth() + 1 < 10 ? '0' + (dateValue.getMonth() + 1) : dateValue.getMonth() + 1;
68		return dateValue.getFullYear() + splitter + month;
69	},
70	
71	getToday : function () {
72		var today = new Date();
73		
74		var month = today.getMonth() + 1 < 10 ? '0' + (today.getMonth() + 1) : today.getMonth() + 1;
75		var day = today.getDate() < 10 ? '0' + (today.getDate()) : today.getDate();
76		
77		return today.getFullYear() + '-' + month + '-' + day;
78	},
79	getThisMonth : function () {
80		var today = new Date();
81		
82		var month = today.getMonth() + 1 < 10 ? '0' + (today.getMonth() + 1) : today.getMonth() + 1;
83		var day = today.getDate() < 10 ? '0' + (today.getDate()) : today.getDate();
84		
85		return today.getFullYear() + '-' + month;
86	},
87	getPlusDay : function (sourceDateStr, plusDayValue) {
88		var sourceDateSplit = sourceDateStr.split('-');
89		
90		var sourceYear = parseInt(sourceDateSplit[0]);
91		var sourceMonth = parseInt(sourceDateSplit[1]);
92		var sourceDay = parseInt(sourceDateSplit[2]);
93		
94		var sourceDate = new Date(sourceYear, sourceMonth, sourceDay, 0, 0, 0, 0);
95		
96		sourceDate.setDate(sourceDate.getDate() + plusDayValue);
97		
98		var month = sourceDate.getMonth() < 10 ? '0' + sourceDate.getMonth() : sourceDate.getMonth();
99		var day = sourceDate.getDate() < 10 ? '0' + sourceDate.getDate() : sourceDate.getDate();
100		
101		return sourceDate.getFullYear() + '-' + month + '-' + day;
102	},
103	getMinusDay : function (sourceDateStr, minusDayValue) {
104		var sourceDateSplit = sourceDateStr.split('-');
105		//console.log(sourceDateStr);
106		var sourceYear = parseInt(sourceDateSplit[0]);
107		var sourceMonth = parseInt(sourceDateSplit[1]) -1;
108		var sourceDay = parseInt(sourceDateSplit[2]); 
109		
110		var sourceDate = new Date(sourceYear, sourceMonth, sourceDay, 0, 0, 0, 0);
111
112		sourceDate.setDate(sourceDate.getDate() - minusDayValue);
113
114		//Date.today().add(1).day()
115		var month = sourceDate.getMonth() < 10 ? '0' + (sourceDate.getMonth()+1) : sourceDate.getMonth()+1;
116		var day = sourceDate.getDate() < 10 ? '0' + sourceDate.getDate() : sourceDate.getDate();
117
118		return sourceDate.getFullYear() + '-' + month + '-' + day;
119	},
120	getMinusMonth : function (sourceDateStr, minusMonthValue) {
121		var sourceDateSplit = sourceDateStr.split('-');
122		
123		var sourceYear = parseInt(sourceDateSplit[0]);
124		var sourceMonth = parseInt(sourceDateSplit[1]);
125		var sourceDay = parseInt(sourceDateSplit[2]);
126		
127		var sourceDate = new Date(sourceYear, sourceMonth, sourceDay, 0, 0, 0, 0);
128		
129		sourceDate.setMonth(sourceDate.getMonth() - minusMonthValue);
130		
131		var month = sourceDate.getMonth() < 10 ? '0' + sourceDate.getMonth() : sourceDate.getMonth();
132		var day = sourceDate.getDate() < 10 ? '0' + sourceDate.getDate() : sourceDate.getDate();
133		
134		return sourceDate.getFullYear() + '-' + month + '-' + day;
135	},
136	getTimestampStartDate : function (sourceDateStr, splitter) {
137		var sourceDateSplit = sourceDateStr.split(splitter);
138		
139		var sourceYear = parseInt(sourceDateSplit[0]);
140		var sourceMonth = parseInt(sourceDateSplit[1]);
141		var sourceDate = parseInt(sourceDateSplit[2]);
142		
143		return new Date(sourceYear, sourceMonth - 1, sourceDate).getTime();
144	},
145	getTimestampEndDate : function (sourceDateStr, splitter) {
146		var sourceDateSplit = sourceDateStr.split(splitter);
147		
148		var sourceYear = parseInt(sourceDateSplit[0]);
149		var sourceMonth = parseInt(sourceDateSplit[1]);
150		var sourceDate = parseInt(sourceDateSplit[2]) + 1;
151		
152		return new Date(sourceYear, sourceMonth - 1, sourceDate).getTime();
153	},
154	getPlusDayTimestamp : function (sourceDateStr, plusDayValue) {
155		var sourceDateSplit = sourceDateStr.split('-');
156		
157		var sourceYear = parseInt(sourceDateSplit[0]);
158		var sourceMonth = parseInt(sourceDateSplit[1]);
159		var sourceDate = parseInt(sourceDateSplit[2]);
160		
161		var sourceDate = new Date(sourceYear, sourceMonth - 1, sourceDate, 0, 0, 0, 0);
162		
163		sourceDate.setDate(sourceDate.getDate() + plusDayValue);
164		
165		//var month = sourceDate.getMonth() < 10 ? '0' + sourceDate.getMonth() : sourceDate.getMonth();
166		//var day = sourceDate.getDate() < 10 ? '0' + sourceDate.getDate() : sourceDate.getDate();
167		return sourceDate.getTime();
168	},
169	getDateTypeValue : function (sourceDateStr, splitter) {
170		var sourceDateSplit = sourceDateStr.split(splitter);
171		
172		var sourceYear = parseInt(sourceDateSplit[0]);
173		var sourceMonth = parseInt(sourceDateSplit[1]);
174		var sourceDate = parseInt(sourceDateSplit[2]);
175		
176		return new Date(sourceYear, sourceMonth - 1, sourceDate);
177	},
178	getCustomDateOnly : function (date) {
179		var result = '';
180		try {
181			if( date ) {
182				var year = date.getFullYear();
183				if ( year ) {
184					var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
185					var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
186					
187					result = year + '-' + month + '-' + day;
188				}
189			}
190		} catch(e) {}
191		
192		return result;
193	},
194	getCustomTimeOnly : function (date) {
195		if( date ) {
196			var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
197			var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
198			var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
199			
200			return hour + ':' + minute + ':' + second;
201		}
202	},
203	getCustomDate : function (date) {
204		if( date ) {
205			var year = date.getFullYear();
206			var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
207			var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
208			
209			var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
210			var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
211			var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
212			
213			return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
214		}
215	},
216	getCustomDateMsec : function (date) {
217		if( date ) {
218			var year = date.getFullYear();
219			var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
220			var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
221			
222			var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
223			var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
224			var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
225			var msec = date.getMilliseconds() < 10 ? '00' + date.getMilliseconds() : (date.getMilliseconds() < 100 ? "0" : date.getMilliseconds());
226			
227			return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second + " " + msec;
228		}
229	},
230
231	getChatMessageTime : function (date) {
232		if( date ) {
233			//var year = date.getFullYear();
234			//var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
235			//var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
236			
237			var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
238			var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
239			var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
240			//var msec = date.getMilliseconds() < 10 ? '00' + date.getMilliseconds() : (date.getMilliseconds() < 100 ? "0" : date.getMilliseconds());
241			
242			return hour + ':' + minute + ':' + second;
243		}
244	},
245	
246	
247	getCustomHourOnly : function (date) {
248		if( date ) {
249			var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
250			
251			return hour;
252		}
253	},
254	getCustomMonthDateOnly : function (date, splitter) {
255		if( date ) {
256			var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
257			var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
258			
259			return month + splitter + day;
260		}
261	},
262	getCustomYearMonthOnly : function (date, splitter) {
263		if( date ) {
264			var year = date.getFullYear();
265			var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
266			
267			return year + splitter + month;
268		}
269	},
270
271	
272	
273	
274	getDiffDays : function (first, second) {
275		return ((second - first) / (1000 * 60 * 60 * 24)) - 1;
276	},
277	getDateTimeMsec : function (cellvalue) {
278		if(cellvalue != null) {
279			var date = new Date(cellvalue);
280		
281			return dateUtils.getCustomDateMsec(date);
282		} else {
283			return '';
284		}
285	},
286	
287	
288	/**
289	 * Local Time과 UTC Time 처리.
290	 */
291	timeLocal2UTC: function(timeLocal, timeFormat) {
292		if (!timeLocal || timeLocal.length < 5) return "";
293		//var isoDate = new Date(timeLocal).toISOString();
294		if (timeFormat == "MM/dd/yyyy") {
295			let arr = timeLocal.split(/[/ :]/);
296			adjusted_date = new Date(arr[2], arr[0]-1, arr[1], arr[3], arr[4], arr[5]);
297		} else {								// yyyy-MM-dd
298			let arr = timeLocal.split(/[- :]/);
299			adjusted_date = new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]);			
300		}
301		var isoDate = new Date(adjusted_date).toISOString();
302		return isoDate;
303	},
304	
305
306
307	addDay: function(date, day){
308
309	    var temp = new Date(date.getFullYear(), date.getMonth(), date.getDate() + day);
310	    return temp; 
311	}
312
313};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.