1 2 3Date.prototype.format = function (format) { 4 var returnStr = ''; 5 var replace = Date.replaceChars; 6 for (var i = 0; i < format.length; i++) { 7 var curChar = format.charAt(i); 8 if (i - 1 >= 0 && format.charAt(i - 1) == "\\") { 9 returnStr += curChar; 10 } 11 else if (replace[curChar]) { 12 returnStr += replace[curChar].call(this); 13 } else if (curChar != "\\") { 14 returnStr += curChar; 15 } 16 } 17 return returnStr; 18}; 19 20Date.replaceChars = { 21 shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], 22 longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 23 shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 24 longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], 25 // Day 26 d: function () { 27 return (this.getDate() < 10 ? '0' : '') + this.getDate(); 28 }, 29 D: function () { 30 return Date.replaceChars.shortDays[this.getDay()]; 31 }, 32 j: function () { 33 return this.getDate(); 34 }, 35 l: function () { 36 return Date.replaceChars.longDays[this.getDay()]; 37 }, 38 N: function () { 39 return this.getDay() + 1; 40 }, 41 S: function () { 42 return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); 43 }, 44 w: function () { 45 return this.getDay(); 46 }, 47 z: function () { 48 var d = new Date(this.getFullYear(), 0, 1); 49 return Math.ceil((this - d) / 86400000); 50 }, // Fixed now 51 // Week 52 W: function () { 53 var d = new Date(this.getFullYear(), 0, 1); 54 return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7); 55 }, // Fixed now 56 // Month 57 F: function () { 58 return Date.replaceChars.longMonths[this.getMonth()]; 59 }, 60 m: function () { 61 return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); 62 }, 63 M: function () { 64 return Date.replaceChars.shortMonths[this.getMonth()]; 65 }, 66 n: function () { 67 return this.getMonth() + 1; 68 }, 69 t: function () { 70 var d = new Date(); 71 return new Date(d.getFullYear(), d.getMonth(), 0).getDate() 72 }, // Fixed now, gets #days of date 73 // Year 74 L: function () { 75 var year = this.getFullYear(); 76 return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)); 77 }, // Fixed now 78 o: function () { 79 var d = new Date(this.valueOf()); 80 d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3); 81 return d.getFullYear(); 82 }, //Fixed now 83 Y: function () { 84 return this.getFullYear(); 85 }, 86 y: function () { 87 return ('' + this.getFullYear()).substr(2); 88 }, 89 // Time 90 a: function () { 91 return this.getHours() < 12 ? 'am' : 'pm'; 92 }, 93 A: function () { 94 return this.getHours() < 12 ? 'AM' : 'PM'; 95 }, 96 B: function () { 97 return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTCMinutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24); 98 }, // Fixed now 99 g: function () { 100 return this.getHours() % 12 || 12; 101 }, 102 G: function () { 103 return this.getHours(); 104 }, 105 h: function () { 106 return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); 107 }, 108 H: function () { 109 return (this.getHours() < 10 ? '0' : '') + this.getHours(); 110 }, 111 i: function () { 112 return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); 113 }, 114 s: function () { 115 return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); 116 }, 117 u: function () { 118 var m = this.getMilliseconds(); 119 return (m < 10 ? '00' : (m < 100 ? 120 '0' : '')) + m; 121 }, 122 // Timezone 123 e: function () { 124 return "Not Yet Supported"; 125 }, 126 I: function () { 127 var DST = null; 128 for (var i = 0; i < 12; ++i) { 129 var d = new Date(this.getFullYear(), i, 1); 130 var offset = d.getTimezoneOffset(); 131 132 if (DST === null) 133 DST = offset; 134 else if (offset < DST) { 135 DST = offset; 136 break; 137 } else if (offset > DST) 138 break; 139 } 140 return (this.getTimezoneOffset() == DST) | 0; 141 }, 142 O: function () { 143 return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; 144 }, 145 P: function () { 146 return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00'; 147 }, // Fixed now 148 T: function () { 149 var m = this.getMonth(); 150 this.setMonth(0);
151 var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); 152 this.setMonth(m); 153 return result; 154 }, 155 Z: function () { 156 return -this.getTimezoneOffset() * 60; 157 }, 158 // Full Date/Time 159 c: function () { 160 return this.format("Y-m-d\\TH:i:sP"); 161 }, // Fixed now 162 r: function () { 163 return this.toString(); 164 }, 165 U: function () { 166 return this.getTime() / 1000; 167 } 168};
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.