PageSourceSearch

https://xregis.western.ac.th/js/sarunrd/datetime_util-0.4.js

js western.ac.th collected 2026-10-02 17:05:21 UTC 26,025 bytes, 675 lines download raw bytes

1//ฟังก์ชั่นแสดงวันที่และเวลา
2function showdatetime(dt) {
3    let mo;
4    let yr = parseFloat(dt.substring(0, 4)) + 543;
5    let mo_tmp = dt.substring(5, 7);
6    switch (mo_tmp) {
7        case "01":
8            mo = "มกราคม";
9            break;
10        case "02":
11            mo = "กุมภาพันธ์";
12            break;
13        case "03":
14            mo = "มีนาคม";
15            break;
16        case "04":
17            mo = "เมษายน";
18            break;
19        case "05":
20            mo = "พฤษภาคม";
21            break;
22        case "06":
23            mo = "มิถุนายน";
24            break;
25        case "07":
26            mo = "กรกฎาคม";
27            break;
28        case "08":
29            mo = "สิงหาคม";
30            break;
31        case "09":
32            mo = "กันยายน";
33            break;
34        case "10":
35            mo = "ตุลาคม";
36            break;
37        case "11":
38            mo = "พฤศจิกายน";
39            break;
40        case "12":
41            mo = "ธันวาคม";
42            break;
43        default:
44            mo = dt;
45
46    }
47    let day = dt.substring(8, 10);
48    let hr = dt.substring(11, 13);
49    let min = dt.substring(14, 16);
50    let sec = dt.substring(17, 19);
51    let output = day + " " + mo + " " + yr + " " + hr + ":" + min + ":" + sec;
52    return output;
53}
54
55function showtime(dt) {
56    let hr = dt.substring(11, 13);
57    let min = dt.substring(14, 16);
58    let sec = dt.substring(17, 19);
59    let output = hr + ":" + min + ":" + sec;
60    return output;
61}
62
63////////// Sarun. Update
64
65/// sarunrd for text area input with html tag
66/// A potentially dangerous Request.Form value was detected from the client (DetailName="yes <br/> I see").
67function htmlEncode(value) {
68    //create a in-memory div, set it's inner text(which jQuery automatically encodes)
69    //then grab the encoded contents back out.  The div never exists on the page.
70    return $('<div/>').text(value).html();
71}
72
73function htmlDecode(value) {
74    return $('<div/>').html(value).text();
75}
76
77let constants = Object.freeze({
78    "DMY": '',
79    "e": 2.718281828459045,
80    "i": Math.sqrt(-1)
81});
82
83///////////////////////////
84/// String extend prototype
85///  "2016-01-16T09:00:00"
86String.prototype.fromYMDtoDMY = function (offset) {
87    offset = offset || 0;
88    //let dd = value.substr(8, 2), mm = value.substr(5, 2);
89    let yy = parseInt(this.substr(0, 4)) + parseInt(offset);
90
91    return this.substr(8, 2) + '/' + this.substr(5, 2) + '/' + yy;
92};
93String.prototype.jsonDate2DmyHms = function () {
94    if (this.length >= 20 && this.startWith('/Date(')) { /// '/Date(1438361940000)/'
95        let mydate = eval(this.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
96        return mydate.toStringDmyHms();
97    }
98    return this;
99};
100String.prototype.jsonDate2Dmy = function () {
101    if (this.length >= 20 && this.startWith('/Date(')) { /// '/Date(1438361940000)/'
102        let mydate = eval(this.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
103        return mydate.toStringDmy();
104    }
105    return this;
106};
107String.prototype.startWith = function (needle) {
108    //return ( this.indexOf(needle) === 0 );
109    //console.log( this.slice(0, needle.length) + ' ' + needle );
110    return this.slice(0, needle.length) === needle;
111};
112String.prototype.isEmpty = function () {
113    return (this.length === 0 || !this.trim());
114};
115String.prototype.getContentInBody = function () {
116    let p1 = this.indexOf('<body');
117    if (p1 === -1) return '';
118
119    let p2 = this.indexOf('>', p1);
120    if (p2 === -1) p2 = p1 + 5;
121    p2++;
122
123    let p3 = this.indexOf('</body>', p2);
124    if (p3 === -1) return '';
125
126    let content = this.substring(p2, p3);
127    return content;
128}
129
130String.prototype.toDate = function (fmt, offset) {
131    if (this.isEmpty()) return new Date();
132
133    offset = offset || 0;
134
135    if (fmt === 'dmy' && this.length >= 10) {
136        let dd = parseInt(this.substr(0, 2)),
137            mm = parseInt(this.substr(3, 2)),
138            yyyy = parseInt(this.substr(6, 4));
139
140        //console.log(dd + ' ' + mm + ' ' + yyyy + ' ' + offset);
141        let now = new Date(yyyy + offset, mm - 1, dd); /// defaut it parse to UTC zone
142        //console.log(now);
143        //console.log(now.toLocaleString());
144        //console.log(now.getTimezoneOffset());     /// TimeZone +7 return -420
145        //if (now.getTimezoneOffset() > 0) now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
146        //else if (now.getTimezoneOffset() < 0) now.setTime(now.getTime() + (-now.getTimezoneOffset() * 60 * 1000));
147        if (now.getTimezoneOffset() !== 0) now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
148        //console.log(now);
149        return now;
150    }
151    if (fmt === 'ymd' && this.length >= 10) {
152        let dd = parseInt(this.substr(8, 2)),
153            mm = parseInt(this.substr(5, 2)),
154            yyyy = parseInt(this.substr(0, 4));
155
156        let now = new Date(yyyy + offset, mm - 1, dd, 0, 0, 0, 0);
157        //if (now.getTimezoneOffset() > 0) now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
158        //else if (now.getTimezoneOffset() < 0) now.setTime(now.getTime() + (-now.getTimezoneOffset() * 60 * 1000));
159        if (now.getTimezoneOffset() !== 0) now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
160        return now;
161    }
162    if (fmt === 'ymdhms' && this.length >= 19) {
163        let dd = parseInt(this.substr(8, 2)),
164            mm = parseInt(this.substr(5, 2)),
165            yyyy = parseInt(this.substr(0, 4));
166        let hr = parseInt(this.substr(11, 2)),
167            min = parseInt(this.substr(14, 2)),
168            sec = parseInt(this.substr(17, 2));
169
170        let now = new Date(yyyy + offset, mm - 1, dd, hr, min, sec, 0);
171        //if (now.getTimezoneOffset() > 0) now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
172        //else if (now.getTimezoneOffset() < 0) now.setTime(now.getTime() + (-now.getTimezoneOffset() * 60 * 1000));
173        if (now.getTimezoneOffset() !== 0) now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
174        return now;
175    }
176
177    if (fmt === 'json') {
178        return eval(this.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
179    }
180    return new Date();
181};
182String.prototype.convertToDate = function (fmt, offset) {
183    // fmt -> json '/Date(1438361940000)/'
184    // fmt -> ymd  '2015-08-28T17:00:00.000Z'
185
186    if (this.isEmpty()) return new Date();
187
188    offset = offset || 0;
189
190    if (fmt === 'json') {
191        return eval(this.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
192    } else if (fmt === 'ymd') {
193        let dd = this.substr(8, 2),
194            mm = this.substr(5, 2),
195            yyyy = this.substr(0, 4);
196        let hr = this.substr(11, 2),
197            min = this.substr(14, 2),
198            sec = this.substr(17, 2);
199
200        let now = new Date(parseInt(yyyy) + offset, parseInt(mm) - 1, parseInt(dd), parseInt(hr), parseInt(min), parseInt(sec), 0);
201        if (now.getTimezoneOffset() !== 0) now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
202        return now;
203    }
204    return new Date();
205};
206String.prototype.formatDateTime = function (fmt, offset) {
207    //2016-08-28T06:18:10.000Z
208    // jsondate from ASP.NET is string  '/Date(1438361940000)/'   or '30/07/2015 22:55:00'   '2015-08-28T17:00:00.000Z'
209    // jsondate from Node.JS is string  '2015-08-28T17:00:00.000Z' '2016-06-22T14:20:47.160Z'
210    if (this.isEmpty()) return '';
211    offset = offset || 0;
212    ///console.log('formatDateTime  ' + fmt + offset);
213    ///console.log(this);
214
215    if (this.length >= 20 && this.startWith('/Date(')) {
216        let mydate = eval(value.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
217        return 'mydate';
218    }
219    if (this.length === 19 || this.length === 24) {
220        if (this.substr(0, 10) === '1900-01-01') return ''; /// check case date is null in oracle ...
221        if (this.substr(0, 10) === '1970-01-01') return ''; /// check case date is null in oracle ...
222        if (fmt === 'dmy') {
223            let yyyy = parseInt(this.substr(0, 4)) + offset;
224            return this.substr(8, 2) + '/' + this.substr(5, 2) + '/' + yyyy;
225        } else if (fmt === 'dmyy') {
226            let yyyy = parseInt(this.substr(0, 4)) + offset;
227            let yy = yyyy.toString().substr(2, 2);
228            return this.substr(8, 2) + '/' + this.substr(5, 2) + '/' + yy;
229        } else if (fmt === 'hms') {
230            let hr = this.substr(11, 2),
231                min = this.substr(14, 2),
232                sec = this.substr(17, 2);
233            return hr + ':' + min + ':' + sec;
234        } else if (fmt === 'hm') {
235            let hr = this.substr(11, 2),
236                min = this.substr(14, 2);
237            return hr + ':' + min;
238        } else if (fmt === 'dmyy-hms') {
239            let yyyy = parseInt(this.substr(0, 4)) + offset;
240            let yy = yyyy.toString().substr(2, 2);
241            let dmyy = this.substr(8, 2) + '/' + this.substr(5, 2) + '/' + yy;
242            let hr = this.substr(11, 2),
243                min = this.substr(14, 2),
244                sec = this.substr(17, 2);
245            let hms = hr + ':' + min + ':' + sec;
246            return dmyy + ' - ' + hms;
247        }
248    }
249};
250
251if (typeof String.prototype.padEnd !== 'function') {
252    String.prototype.padEnd = function (targetLength, padString) {
253        let pad = new Array(targetLength).join(padString || ' ');
254        let result = this + pad;
255        return result.substr(0, targetLength);
256    };
257}
258
259//////////////////////////
260
261Number.prototype.formatDateTime = function (fmt) {
262    let mydate = new Date(this);
263    if (fmt === 'dmy') {
264        let yyyy = ('0000' + mydate.getFullYear()).slice(-4),
265            mm = ('00' + (mydate.getMonth() + 1)).slice(-2),
266            dd = ('00' + mydate.getDate()).slice(-2);
267        return dd + '/' + mm + '/' + yyyy;
268    } else if (fmt === 'hms') {
269        let hr = ('00' + mydate.getHours()).slice(-2),
270            min = ('00' + mydate.getMinutes()).slice(-2),
271            sec = ('00' + mydate.getSeconds()).slice(-2);
272        return hr + ':' + min + ':' + sec;
273    } else if (fmt === 'hm') {
274        let hr = ('00' + mydate.getHours()).slice(-2),
275            min = ('00' + mydate.getMinutes()).slice(-2);
276        return hr + ':' + min;
277    }
278};
279/////////////////////////
280/// Date extend prototype
281Date.prototype.toStringDmy = function (offset) {
282    let mydate = this;
283    offset = offset || 0;
284
285    my_yr = ('0000' + (mydate.getFullYear() + offset)).slice(-4);
286    my_month = ('00' + (mydate.getMonth() + 1)).slice(-2);
287    my_day = ('00' + mydate.getDate()).slice(-2);
288
289    return my_day + '/' + my_month + '/' + my_yr;
290};
291Date.prototype.toStringDmyHms = function () {
292    let mydate = this;
293
294    my_yr = ('0000' + mydate.getFullYear()).slice(-4);
295    my_month = ('00' + (mydate.getMonth() + 1)).slice(-2);
296    my_day = ('00' + mydate.getDate()).slice(-2);
297
298    my_hr = ('00' + mydate.getHours()).slice(-2);
299    my_min = ('00' + mydate.getMinutes()).slice(-2);
300    my_sec = ('00' + mydate.getSeconds()).slice(-2);
301
302    return my_day + '/' + my_month + '/' + my_yr + ' ' + my_hr + ':' + my_min + ':' + my_sec;
303};
304Date.prototype.toStringHm = function () {
305    let mydate = this;
306
307    my_hr = ('00' + mydate.getHours()).slice(-2);
308    my_min = ('00' + mydate.getMinutes()).slice(-2);
309
310    return my_hr + ':' + my_min;
311};
312Date.prototype.toStringHms = function () {
313    let mydate = this;
314
315    my_hr = ('00' + mydate.getHours()).slice(-2);
316    my_min = ('00' + mydate.getMinutes()).slice(-2);
317    my_sec = ('00' + mydate.getSeconds()).slice(-2);
318
319    return my_hr + ':' + my_min + ':' + my_sec;
320};
321Date.prototype.Equal = function (val) {
322    let mydate = this;
323
324    if (mydate.getFullYear() === val.getFullYear() &&
325        mydate.getMonth() === val.getMonth() &&
326        mydate.getDate() === val.getDate())
327        return true;
328
329    return false;
330};
331
332let fn_string = function () {
333    let
334        JsonDate2DmyHms = function (value) {
335            // jsondate from ASP.NET is string  '/Date(1438361940000)/'
336            //                                   /Date(275072400000)/
337            //console.log(value);
338            if (value === null) return '';
339            if (value.length >= 20 && value.startWith('/Date(')) {
340                let mydate = eval(value.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
341                //console.log( 'is json date '+ value);
342                //console.log( mydate + ' '+ mydate.toStringDmy());
343                return mydate.toStringDmyHms();
344            }
345            return value;
346        },
347        isTimeValid_hhmm = function (time) {
348            let timePattern = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/g;
349            return timePattern.test(time);
350        },
351        isTimeValid_hhmmss = function (time) {
352            let timePattern = /^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/g;
353            let resultFrom = timePattern.test(time);
354        }
355
356    return {
357        JsonDate2DmyHms: JsonDate2DmyHms,
358        isTimeValid_hhmm: isTimeValid_hhmm,
359        isTimeValid_hhmmss: isTimeValid_hhmmss
360    }
361}
362
363let convertDmyToTimeMs = (function (dmy, offset) {
364    if (_.isUndefined(dmy)) return 0;
365    if (!_.isString(dmy)) return dmy;
366    if (dmy.isEmpty()) return 0;
367    if (dmy.length !== 8 && dmy.length !== 10) return 0;
368
369    offset = offset || 0;
370
371    let dd = parseInt(dmy.substr(0, 2)),
372        mm = parseInt(dmy.substr(3, 2));
373    let yyyy = dmy.length === 10 ? parseInt(dmy.substr(6, 4)) : parseInt(dmy.substr(6, 2));
374
375    if (offset !== 0 && yyyy < 100) {
376        yyyy = 2500 + yyyy; /// make 59 -> 2559
377    }
378
379    let now = new Date(yyyy + offset, mm - 1, dd); /// defaut it parse to UTC zone
380    now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
381
382    // return now.getTime() >= -2147483648 ? now.getTime():0;
383    return now.getTime()
384});
385let convertDmyHmsToTimeMs = (function (dmy, hms, offset) {
386    if (_.isUndefined(dmy)) return 0;
387    if (dmy.isEmpty()) return 0;
388    if (dmy.length !== 8 && dmy.length !== 10) return 0;
389
390    offset = offset || 0;
391
392    /// support 'dd/mm/yyyy''  and  'dd/mm/yy'
393    let dd = parseInt(dmy.substr(0, 2)),
394        mm = parseInt(dmy.substr(3, 2));
395    let yyyy = dmy.length === 10 ? parseInt(dmy.substr(6, 4)) : parseInt(dmy.substr(6, 2));
396
397    if (offset !== 0 && yyyy < 100) {
398        yyyy = 2500 + yyyy; /// make 59 -> 2559
399    }
400
401    /// support 'hh:mm:ss'
402    let hh = 0,
403        min = 0,
404        ss = 0;
405    let hmsArray = hms.split(':');
406    if (hmsArray.length >= 2 && hmsArray[0]) hh = parseInt(hmsArray[0]);
407    if (hmsArray.length >= 2 && hmsArray[1]) min = parseInt(hmsArray[1]);
408    if (hmsArray.length >= 3 && hmsArray[2]) ss = parseInt(hmsArray[2]);
409    /*
410        if (hms.length === 5 || hms.length === 8) {
411            hh = parseInt(hms.substr(0, 2)),
412                min = parseInt(hms.substr(3, 2)),
413                ss = 0;
414            if (hms.length === 8)
415                ss = parseInt(hms.substr(5, 2));
416        }*/
417
418    let now = new Date(yyyy + offset, mm - 1, dd, hh, min, ss); /// defaut it parse to UTC zone
419    if (now.getTimezoneOffset() !== 0) now.setTime(now.getTime() - (now.getTimezoneOffset() * 60 * 1000));
420    return now.getTime();
421});
422
423let fn_datetime_utils = function () {
424    let
425        formatDateTime = function (value, fmt, offset) {
426            if (value) {
427                return value.formatDateTime(fmt, offset);
428            } else return '';
429        },
430        convertJsonDate2Dmy = function (value) {
431            // jsondate from ASP.NET is string  '/Date(1438361940000)/'   or '30/07/2015 22:55:00'   '2015-08-28T17:00:00.000Z'
432            //                                   /Date(275072400000)/
433            //console.log(value);
434            if (value === null) return '';
435            if (value.length == 10) { /// 30/7/2015
436                return value;
437            } else if (value.length > 10 && value.length < 20) { /// 30/07/2015 22:55:00
438                return value.substr(0, 10);
439            } else if (value.length >= 20 && value.startWith('/Date(')) {
440                let mydate = eval(value.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
441                //console.log( 'is json date '+ value);
442                //console.log( mydate + ' '+ mydate.toStringDmy());
443                return mydate.toStringDmy();
444            }
445            return value;
446        },
447        convertJsonDate2DmyHms = function (value) {
448            // jsondate from ASP.NET is string  '/Date(1438361940000)/'
449            //                                   /Date(275072400000)/
450            //console.log(value);
451            if (value === null) return '';
452            if (value.length >= 20 && value.startWith('/Date(')) {
453                let mydate = eval(value.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
454                //console.log( 'is json date '+ value);
455                //console.log( mydate + ' '+ mydate.toStringDmy());
456                return mydate.toStringDmyHms();
457            }
458            return value;
459        },
460        convertJson2Date = function (value) {
461            // jsondate from ASP.NET is string  '/Date(1438361940000)/'
462            // or '30/07/2015 22:55:00'   '2015-11-13T00:00:00'  '2015-08-28T17:00:00.000Z'  '2015-11-25T14:37:10.0989585'
463            //                                                                               '2015-11-25T20:45:49.291224'
464            //console.log(typeof value);         /Date(-50655600000)/
465
466            ///console.log(typeof value);
467            if (typeof value !== 'string') return null;
468            //if (value === null) return null;
469
470            if (value.isEmpty()) return null;
471
472            if (value.length === 10) {
473                let dd = value.substr(0, 2),
474                    mm = value.substr(3, 2),
475                    yy = value.substr(6, 4);
476
477                let mydate = new Date(parseInt(yy), parseInt(mm) - 1, parseInt(dd), 0, 0, 0, 0);
478                return mydate;
479            } else if (value.length >= 20 && value.startWith('/Date(')) { /// '/Date(1438361940000)/'
480                //let mydate = eval(value.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
481                let mydate = new Date(parseInt(value.substr(6)));
482
483                return mydate;
484            } else if (value.length === 19 || value.length > 24) {
485                // 2015-12-23T17:00:00  /// '2015-11-13T00:00:00'  '2015-08-28T17:00:00.000Z'
486                if (value.substr(4, 1) === '-' && value.substr(10, 1) === 'T') {
487                    //let mydate = new Date(value);
488                    let dd = value.substr(8, 2),
489                        mm = value.substr(5, 2),
490                        yy = value.substr(0, 4);
491                    let hr = value.substr(11, 2),
492                        min = value.substr(14, 2),
493                        sec = value.substr(17, 2);
494
495                    let mydate = new Date(parseInt(yy), parseInt(mm) - 1, parseInt(dd), parseInt(hr), parseInt(min), parseInt(sec), 0);
496                    return mydate;
497                }
498
499                let dd = value.substr(0, 2),
500                    mm = value.substr(3, 2),
501                    yy = value.substr(6, 4);
502                let hr = value.substr(11, 2),
503                    min = value.substr(14, 2),
504                    sec = value.substr(17, 2);
505
506                let mydate = new Date(parseInt(yy), parseInt(mm) - 1, parseInt(dd), parseInt(hr), parseInt(min), parseInt(sec), 0);
507                return mydate;
508            }
509
510            console.log('[' + value + ']');
511            console.log(typeof value);
512            console.log('convertJson2Date   --> invalid json date');
513            return value;
514        },
515        convertValue2Date = function (value) {
516
517            if (typeof value === 'string') {
518                return convertJson2Date(value);
519            } else if (typeof value === 'object') { // typeof 'object' mean to Date,
520                return value;
521            }
522
523            //console.log('[' + value + ']');
524            //console.log(typeof value);
525            console.log('convertValue2Date   --> invalid json date');
526            return value;
527        },
528        convertString2Date = function (value) {
529            // jsondate from ASP.NET is string  '/Date(1438361940000)/'   or '30/07/2015 22:55:00'   '2015-08-28T17:00:00.000Z'
530            //console.log(typeof value);         /Date(-50655600000)/
531
532            //console.log(typeof value);
533            if (typeof value !== 'string') return null;
534            //if (value === null) return null;
535
536            if (value.isEmpty()) return null;
537
538            if (value.length === 10) {
539                let dd = value.substr(0, 2),
540                    mm = value.substr(3, 2),
541                    yy = value.substr(6, 4);
542
543                let mydate = new Date(parseInt(yy), parseInt(mm) - 1, parseInt(dd), 0, 0, 0, 0);
544                return mydate;
545            } else if (value.length === 19) {
546                let dd = value.substr(0, 2),
547                    mm = value.substr(3, 2),
548                    yy = value.substr(6, 4);
549                let hr = value.substr(11, 2),
550                    min = value.substr(14, 2),
551                    sec = value.substr(17, 2);
552
553                let mydate = new Date(parseInt(yy), parseInt(mm) - 1, parseInt(dd), parseInt(hr), parseInt(min), parseInt(sec), 0);
554                return mydate;
555            } else if (value.length >= 20 && value.startWith('/Date(')) {
556                let mydate = eval(value.replace(/\/Date\((-?\d+)\)\//gi, "new Date($1)"));
557                return mydate;
558            }
559
560            console.log('[' + value + ']');
561            console.log(typeof value);
562            console.log('   --> invalid json date');
563            return value;
564        },
565        convertDate2DMY = function (mydate) {
566            if (typeof mydate !== 'object') return '';
567
568            my_yr = ('0000' + mydate.getFullYear()).slice(-4);
569            my_month = ('00' + (mydate.getMonth() + 1)).slice(-2);
570            my_day = ('00' + mydate.getDate()).slice(-2);
571
572            return my_day + '/' + my_month + '/' + my_yr;
573        },
574        convertDate2HM = function (mydate) {
575            if (typeof mydate !== 'object') return '';
576
577            my_hr = ('00' + mydate.getHours()).slice(-2);
578            my_min = ('00' + mydate.getMinutes()).slice(-2);
579            my_sec = ('00' + mydate.getSeconds()).slice(-2);
580
581            return my_hr + ':' + my_min;
582        },
583        isTimeValid_hhmm = function (time) {
584            let timePattern = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/g;
585            return timePattern.test(time);
586        },
587        isTimeValid_hhmmss = function (time) {
588            let timePattern = /^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/g;
589            let resultFrom = timePattern.test(time);
590        }
591
592    return {
593        formatDateTime: formatDateTime,
594        convertDmyToTimeMs: convertDmyToTimeMs,
595        convertJsonDate2Dmy: convertJsonDate2Dmy,
596        convertJsonDate2DmyHms: convertJsonDate2DmyHms,
597        convertJson2Date: convertJson2Date,
598        convertString2Date: convertString2Date,
599        convertValue2Date: convertValue2Date,
600        convertDate2DMY: convertDate2DMY,
601        convertDate2HM: convertDate2HM,
602        isTimeValid_hhmm: isTimeValid_hhmm,
603        isTimeValid_hhmmss: isTimeValid_hhmmss
604    }
605};
606
607/// get parameter value from url syntax
608function getParameterByName(name, url) {
609    if (!url) url = window.location.href;
610    name = name.replace(/[\[\]]/g, "\\$&");
611    let regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
612        results = regex.exec(url);
613    if (!results) return null;
614    if (!results[2]) return '';
615    return decodeURIComponent(results[2].replace(/\+/g, " "));
616}
617
618/**
619 * Fast UUID generator, RFC4122 version 4 compliant.
620 * @author Jeff Ward (jcward.com).
621 * @license MIT license
622 * @link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
623 **/
624let UUID = (function () {
625    let self = {};
626    let lut = [];
627    for (let i = 0; i < 256; i++) {
628        lut[i] = (i < 16 ? '0' : '') + (i).toString(16);
629    }
630    self.generate = function () {
631        let d0 = Math.random() * 0xffffffff | 0;
632        let d1 = Math.random() * 0xffffffff | 0;
633        let d2 = Math.random() * 0xffffffff | 0;
634        let d3 = Math.random() * 0xffffffff | 0;
635        return lut[d0 & 0xff] + lut[d0 >> 8 & 0xff] + lut[d0 >> 16 & 0xff] + lut[d0 >> 24 & 0xff] + '-' +
636            lut[d1 & 0xff] + lut[d1 >> 8 & 0xff] + '-' + lut[d1 >> 16 & 0x0f | 0x40] + lut[d1 >> 24 & 0xff] + '-' +
637            lut[d2 & 0x3f | 0x80] + lut[d2 >> 8 & 0xff] + '-' + lut[d2 >> 16 & 0xff] + lut[d2 >> 24 & 0xff] +
638            lut[d3 & 0xff] + lut[d3 >> 8 & 0xff] + lut[d3 >> 16 & 0xff] + lut[d3 >> 24 & 0xff];
639    };
640    self._p8 = function (s) {
641        let p = (Math.random().toString(16) + "000000000").substr(2, 8);
642        return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p;
643    }
644    self.guid = function () {
645        return self._p8() + self._p8(true) + self._p8(true) + self._p8();
646    }
647    return self;
648})();
649
650let setYearToBC = (function (date) {
651    if (date === null) return date;
652    if (_.isUndefined(date)) return date;
653    if (!_.isString(date)) return date;
654    if (date.isEmpty()) return date;
655    if (date.length !== 8 && date.length !== 10) return date;
656
657    // console.log('date before', date)
658    if(typeof date === 'string') {
659        //convert string to date
660        // 09/04/1987
661        const [day, month, year] = date.split('/');
662        // console.log('year', year)
663        // console.log('month', month)
664        // console.log('day', day)
665        date = new Date(parseInt(year), parseInt(month) - 1, parseInt(day))
666        date.setHours(0, 0, 0, 0)
667    }
668    // console.log('date after', date);
669
670    if(date.getFullYear() >= 2400) {
671        date.setFullYear(date.getFullYear() - 543)
672    }
673
674    return date.toStringDmy()
675});

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.