1/* 2 * ================================================================ 3 * = (c) Koguma.fr - [email protected] = 4 * ================================================================ 5 */ 6 7const ONE_MONTH = 2678400000 ; 8const ONE_WEEK = 604800000 ; 9const ONE_DAY = 86400000 ; 10const ONE_HOUR = 3600000 ; 11const ONE_MINUTE = 60000 ; 12const ONE_SECOND = 1000 ; 13 14Date.prototype.toLocaleISOString = function() { 15 var vDate = ('0000' + this.getFullYear()).slice(-4) + '-' + ('00' + (this.getMonth() + 1)).slice(-2) + '-' + ('00' + this.getDate()).slice(-2) ; 16 var vTime = ('00' + this.getHours()).slice(-2) + ':' + ('00' + this.getMinutes()).slice(-2) + ':' + ('00' + this.getSeconds()).slice(-2) + '.' + ('000' + this.getMilliseconds()).slice(-3) ; ; 17 var vTimezone = ('00'+Math.abs(Math.floor(this.getTimezoneOffset() / 60))).slice(-2) + ':' + ('00'+Math.abs(this.getTimezoneOffset() % 60)).slice(-2) ; 18 19 if (this.getTimezoneOffset() > 0) { 20 vTimezone = '-' + vTimezone ; 21 } else if (this.getTimezoneOffset() < 0) { 22 vTimezone = '+' + vTimezone ; 23 } else { 24 vTimezone = 'Z' ; 25 } 26 27 return vDate + 'T' + vTime + vTimezone ; 28} 29 30Date.prototype.toDateISOString = function() { 31 return ('0000' + this.getFullYear()).slice(-4) + '-' + ('00' + (this.getMonth() + 1)).slice(-2) + '-' + ('00' + this.getDate()).slice(-2) ; 32} 33 34Date.prototype.formatTime = function(aWithSeconds = true) { 35 if (!this.isEmpty()) { 36 var vResult = ' ' + ('00' + this.getHours()).slice(-2) + ':' + ('00' + this.getMinutes()).slice(-2) ; 37 38 if (aWithSeconds) { 39 vResult += ':' + ('00' + this.getSeconds()).slice(-2) ; 40 } 41 } else { 42 vResult = '' ; 43 } 44 45 return vResult ; 46} 47 48Date.prototype.getWeek = function() { 49 var vJanvierFirst = new Date(this.getFullYear(), 0, 1); 50 return Math.ceil((((this - vJanvierFirst) / ONE_DAY) + vJanvierFirst.getDay() + 1) / 7); 51} 52 53Date.prototype.getDayOfYear = function() { 54 var vJanvierFirst = new Date(aDate.getFullYear(),0,0) ; 55 return Math.floor((aDate - vJanvierFirst) / ONE_DAY) ; 56} 57 58Date.prototype.getDatePart = function() { 59 var vDate = new Date(this.getTime()) ; 60 vDate.setHours(0,0,0,0) ; 61 return vDate ; 62} 63 64Date.prototype.setValue = function(aDateStr) { 65 if (aDateStr) { 66 this.setTime(Date.parse(aDateStr)) ; 67 } else { 68 this.setTime(Date.parse('')) ; 69 } 70} 71 72Date.prototype.isEmpty = function() { 73 return isNaN(this.getTime()) ; 74} 75 76Date.prototype.setEmpty = function() { 77 this.setValue('') ; 78} 79 80Date.prototype.setNow = function() { 81 this.setTime((new Date()).getTime()) ; 82} 83 84Date.prototype.formatShort = function(aWithTime = true, aWithSeconds = true) { 85 if (this.isEmpty()) 86 return '' ; 87 88 var vResult = ('00' + this.getDate()).slice(-2) + '/' + ('00' + (this.getMonth() + 1)).slice(-2) + '/' + ('0000' + this.getFullYear()).slice(-4) ; 89 90 if (aWithTime) { 91 vResult += ' ' + ('00' + this.getHours()).slice(-2) + ':' + ('00' + this.getMinutes()).slice(-2) ; 92 93 if (aWithSeconds) { 94 vResult += ':' + ('00' + this.getSeconds()).slice(-2) ; 95 } 96 } 97 98 return vResult ; 99} 100 101Date.prototype.formatFull = function(aWithDay = false) { 102 var vResult = '' ; 103 104 if (aWithDay) { 105 vResult += Date.dayWeekStr[this.getDay()] + ' ' ; 106 } 107 108 vResult += this.getDate() + ' ' + Date.monthStr[this.getMonth()] + ' ' + this.getFullYear() ; 109 110 return vResult ; 111} 112 113Date.prototype.getAge = function() { 114 var vDate = new Date(this.getTime()) ; 115 vDate.setHours(1,0,0,0) ; 116 117 var vDiff = new Date((new Date()).setHours(0,0,0,0) - vDate.getTime()) ; 118 var vAge = Math.max(0, vDiff.getUTCFullYear() - 1970) ; 119 return vAge ; 120} 121 122Date.monthStr = ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"] ; 123Date.dayWeekStr = ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"] ; 124 125 126
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.