PageSourceSearch

https://jii-inforex.co.jp/goods/js/common/date-format.js

js jii-inforex.co.jp collected 2026-09-25 18:32:30 UTC 4,591 bytes, 152 lines download raw bytes

1//“ú•tƒtƒH[ƒ}ƒbƒg•ÏŠ·
2function _dateFormat(date, format) {
3    if (date == null || date == '') {
4        return '';
5    }
6    var tempDate = new Date(date);
7    var tf = function(i) {
8        return (i < 10 ? '0' : '') + i
9    };
10    return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a) {
11        switch (a) {
12        case 'yyyy':
13            return tempDate.getFullYear();
14        case 'MM':
15            return tf(tempDate.getMonth() + 1);
16        case 'mm':
17            return tf(tempDate.getMinutes());
18        case 'dd':
19            return tf(tempDate.getDate());
20        case 'HH':
21            return tf(tempDate.getHours());
22        case 'ss':
23            return tf(tempDate.getSeconds());
24        }
25    })
26  
27}
28//“ú•t‚̃tƒH[ƒ}ƒbƒg,”N‚ðŽæ‚Á‚Ä‚©‚ç2ˆÊ‚ɂȂé
29function _dateYHTFormat(date, format) {
30    if (date == null || date == '') {
31        return '';
32    }
33    var tempDate = new Date(date);
34    var tf = function(i) {
35        return (i < 10 ? '0' : '') + i
36    };
37    return format.replace(/yy|MM|dd|HH|mm|ss/g, function(a) {
38        switch (a) {
39        case 'yy':
40            var year = tempDate.getYear();
41            var finDate = year < 2000 ? year + 1900 : year;
42            return finDate.toString().substr(2, 2);
43        case 'MM':
44            return tf(tempDate.getMonth() + 1);
45        case 'mm':
46            return tf(tempDate.getMinutes());
47        case 'dd':
48            return tf(tempDate.getDate());
49        case 'HH':
50            return tf(tempDate.getHours());
51        case 'ss':
52            return tf(tempDate.getSeconds());
53        }
54    })
55  
56}
57function _dateYMDFormat(dateValue){
58    var value = dateValue.replace(/\s+/g, "");
59    var reDate = /^(?:19|20)[0-9][0-9]\/(?:(?:0[0-9])|(?:1[0-2]))\/(?:(?:[0-2][0-9])|(?:[0-3][0-1]))$/;
60    if(value == "" || value == null){
61        return "";
62    }
63    
64    if(reDate.test(value)){
65        return value;
66    }
67    if(value == 't' || value == 'T'){
68        var nowDate = new Date();
69        return nowDate.getFullYear()+ '/' 
70        + ((nowDate.getMonth()+1) < 10 ? ('0' +(nowDate.getMonth()+1)) : (nowDate.getMonth()+1)) + '/' 
71        + (nowDate.getDate() < 10 ? ('0' +nowDate.getDate()) : nowDate.getDate());
72    }
73    var numPattern=/^\d*$/;
74    if(!numPattern.test(value)){
75        return value;
76    }else if(value.length == 8){
77        return value.substr(0,4) + '/' + value.substr(4,2) + '/' + value.substr(6,2);
78    }else{
79        return value;
80    }
81}
82
83function isValidDate(dateValue, koumoku) {
84    var result = _dateKbn(dateValue);
85    if ("1" == result) {
86        return msgParse(msg.CM000067E, koumoku, "ŒŽ");
87    } else if ("2" == result) {
88        return msgParse(msg.CM000067E, koumoku, "“ú");
89    } else if ("3" == result) {
90        return msgParse(msg.CM000066E, koumoku);
91    } else if ("4" == result) {
92        return msgParse(msg.CM000093E, koumoku);
93    }
94    return "";
95}
96
97// “ú•tŒ^YYYY/MM/DD
98function _dateKbn(dateValue) {
99
100    if (dateValue == "" || dateValue == null) {
101        return "0";
102    }
103
104    var reDate = /^[0-9]+\/[0-9]+\/[0-9]+$/;
105
106    if (!reDate.test(dateValue)) {
107        // ‘Ž®•ÏŠ·‚ðs‚¤A•ÏŠ·ƒGƒ‰[‚̏ꍇ
108        return "3";
109    }
110
111    var value = dateValue.split("/");
112    var intYear = value[0];
113    var intMonth = value[1];
114    var intDay = value[2];
115
116    if (intMonth == 0 || 12 < intMonth) {
117        // “ü—Í“ú•t‚ÌŒŽ‚ªŠÔˆá‚Á‚Ä‚¢‚éê‡
118        return "1";
119    }
120
121    if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12)
122            && (intDay > 31 || intDay < 1)) {
123        // “ü—Í“ú•t‚Ì“ú‚ªŠÔˆá‚Á‚Ä‚¢‚éê‡
124        return "2";
125    }
126    if ((intMonth == 2 || intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11)
127            && (intDay > 30 || intDay < 1)) {
128        // “ü—Í“ú•t‚Ì“ú‚ªŠÔˆá‚Á‚Ä‚¢‚éê‡
129        return "2";
130    }
131    if (intMonth == 2) {
132        var boolLeapYear = false;
133        if (((intYear % 100) == 0 && (intYear % 400) == 0) || (intYear % 4) == 0) {
134            boolLeapYear = true;
135        }
136        if (boolLeapYear && 29 < intDay) {
137            // “ü—Í“ú•t‚Ì“ú‚ªŠÔˆá‚Á‚Ä‚¢‚éê‡
138            return "2";
139        }
140        if (!boolLeapYear && 28 < intDay) {
141            // “ü—Í“ú•t‚Ì“ú‚ªŠÔˆá‚Á‚Ä‚¢‚éê‡
142            return "2";
143        }
144    }
145
146    var intDate = dateValue.replace(new RegExp("/", "gm"), "");
147
148    if (intDate < 19010101 || 29991231 < intDate) {
149        return "4";
150    }
151    return "0";
152}

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.