1if (typeof wp == 'undefined') wp = {}; 2wp.locale = function( translations ) { 3 this.date = function(format, date) { 4 if ('undefined' == typeof date) date = new Date(); 5 var returnStr = ''; 6 var replace = this.replaceChars; 7 var backslashCount = 0; 8 for (var i = 0; i < format.length; i++) { 9 var curChar = format.charAt(i); 10 if (curChar == '\\') { 11 backslashCount++; 12 if (2 == backslashCount) { 13 returnStr += '\\'; 14 backslashCount = 0; 15 } 16 continue; 17 } 18 19 if (replace[curChar] && 0 == backslashCount) { 20 returnStr += replace[curChar].call(date); 21 } else { 22 returnStr += curChar; 23 } 24 25 if (curChar != '\\') backslashCount = 0; 26 } 27 return returnStr; 28 }; 29 30 this.parseISO8601 = function(iso8601){ 31 var regexp = /(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/; 32 33 var matches = iso8601.match(new RegExp(regexp)); 34 if (!matches) return null; 35 var offset = 0; 36 37 var date = new Date(); 38 39 date.setUTCDate(1); 40 date.setUTCFullYear(parseInt(matches[1],10)); 41 date.setUTCMonth(parseInt(matches[3],10) - 1); 42 date.setUTCDate(parseInt(matches[5],10)); 43 date.setUTCHours(parseInt(matches[7],10)); 44 date.setUTCMinutes(parseInt(matches[9],10)); 45 date.setUTCSeconds(parseInt(matches[11],10)); 46 if (matches[12]) 47 date.setUTCMilliseconds(parseFloat(matches[12]) * 1000); 48 if (matches[13] != 'Z') { 49 offset = (matches[15] * 60) + parseInt(matches[17],10); 50 offset *= ((matches[14] == '-') ? -1 : 1); 51 date.setTime(date.getTime() - offset * 60 * 1000); 52 } 53 return date; 54 }; 55 56 var key; 57 for ( key in translations ) { 58 this[ key ] = translations[ key ]; 59 } 60 61 shortMonths = this.monthabbrev; 62 longMonths = this.month; 63 shortDays = this.weekdayabbrev; 64 longDays = this.weekday; 65 66 this.replaceChars = { 67 68 // Day 69 d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); }, 70 D: function() { return shortDays[this.getDay()]; }, 71 j: function() { return this.getDate(); }, 72 l: function() { return longDays[this.getDay()]; }, 73 N: function() { return this.getDay() + 1; }, 74 S: function() { 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'))); }, 75 w: function() { return this.getDay(); }, 76 z: function() { return "Not Yet Supported"; }, 77 // Week 78 W: function() { return "Not Yet Supported"; }, 79 // Month 80 F: function() { return longMonths[this.getMonth()]; }, 81 m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); }, 82 M: function() { return shortMonths[this.getMonth()]; }, 83 n: function() { return this.getMonth() + 1; }, 84 t: function() { return "Not Yet Supported"; }, 85 // Year 86 L: function() { return "Not Yet Supported"; }, 87 o: function() { return "Not Supported"; }, 88 Y: function() { return this.getFullYear(); }, 89 y: function() { return ('' + this.getFullYear()).substr(2); }, 90 // Time 91 a: function() { return this.getHours() < 12 ? 'am' : 'pm'; }, 92 A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; }, 93 B: function() { return "Not Yet Supported"; }, 94 g: function() { return this.getHours() % 12 || 12; }, 95 G: function() { return this.getHours(); }, 96 h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); }, 97 H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); }, 98 i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); }, 99 s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); }, 100 // Timezone 101 e: function() { return "Not Yet Supported"; }, 102 I: function() { return "Not Supported"; }, 103 O: function() { return (this.getTimezoneOffset() < 0 ? '-' : '+') + (this.getTimezoneOffset() / 60 < 10 ? '0' : '') + (this.getTimezoneOffset() / 60) + '00'; }, 104 T: function() { return "Not Yet Supported"; }, 105 Z: function() { return this.getTimezoneOffset() * 60; }, 106 // Full Date/Time 107 c: function() { return "Not Yet Supported"; }, 108 r: function() { return this.toString(); }, 109 U: function() { return this.getTime() / 1000; } 110 }; 111};
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.