Changeset 8669
- Timestamp:
- 05/21/07 06:37:30 (20 months ago)
- Files:
-
- 1 modified
-
dojox/trunk/date/php.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojox/trunk/date/php.js
r8661 r8669 2 2 dojo.require("dojo.date"); 3 3 4 dojox.date.php.format = function(/*Date*/ date, /*String*/ format ){4 dojox.date.php.format = function(/*Date*/ date, /*String*/ format, /*Object?*/ overrides){ 5 5 // summary: Get a formatted string for a given date object 6 6 var df = new dojox.date.php.DateFormat(date); 7 return df.format(format );7 return df.format(format, overrides); 8 8 } 9 9 10 dojox.date.php.DateFormat = function( date){10 dojox.date.php.DateFormat = function(/*Date*/ date){ 11 11 this.date = date; 12 12 } … … 18 18 monthdays: [31,28,31,30,31,30,31,31,30,31,30,31], 19 19 20 format: function(/*String*/ format ){20 format: function(/*String*/ format, /*Object?*/ overrides){ 21 21 // summary: Format the internal date object 22 22 var parts = []; 23 23 for(var i = 0; i < format.length; i++){ 24 24 var chr = format.charAt(i); 25 if(typeof this[chr] == "function"){ 25 if(overrides && typeof overrides[chr] == "function"){ 26 parts.push(overrides[chr].call(this)); 27 }else if(typeof this[chr] == "function"){ 26 28 parts.push(this[chr]()); 27 29 }else{ … … 42 44 D: function(){ 43 45 // summary: A textual representation of a day, three letters 44 return weekdays_3[this.date.getDay()];46 return this.weekdays_3[this.date.getDay()]; 45 47 }, 46 48 … … 52 54 l: function(){ 53 55 // summary: A full textual representation of the day of the week 54 return weekdays[this.date.getDay()];56 return this.weekdays[this.date.getDay()]; 55 57 }, 56 58 … … 79 81 z: function(){ 80 82 // summary: The day of the year (starting from 0) 81 var millis = this.date.getTime() - new Date(this.date.get Year(), 1, 1).getTime();83 var millis = this.date.getTime() - new Date(this.date.getFullYear(), 0, 1).getTime(); 82 84 return Math.floor(millis/86400000) + ""; 83 85 }, … … 88 90 // summary: ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) 89 91 var week; 90 var jan1_w = new Date(this.date.get Year(), 1, 1).getDay() + 1;92 var jan1_w = new Date(this.date.getFullYear(), 0, 1).getDay() + 1; 91 93 var w = this.date.getDay() + 1; 92 94 var z = parseInt(this.z()); 93 95 94 96 if(z <= (8 - jan1_w) && jan1_w > 4){ 95 if(jan1_w == 5 || (jan1_w == 6 && Boolean(this.L()))){ 97 var last_year = new Date(this.date.getFullYear() - 1, this.date.getMonth(), this.date.getDate()); 98 if(jan1_w == 5 || (jan1_w == 6 && dojo.date.isLeapYear(last_year))){ 96 99 week = 53; 97 100 }else{ … … 109 112 }else{ 110 113 var j = z + (7 - w) + (jan1_w - 1); 111 week = j / 7;114 week = Math.ceil(j / 7); 112 115 if(jan1_w > 4){ 113 116 --week; … … 242 245 O: function(){ 243 246 // summary: Difference to Greenwich time (GMT) in hours 244 var off = Math.abs(this.date.getTime ZoneOffset());247 var off = Math.abs(this.date.getTimezoneOffset()); 245 248 var hours = Math.floor(off / 60) + ""; 246 249 var mins = (off % 60) + ""; … … 267 270 // Timezone offset in seconds. The offset for timezones west of UTC is always negative, 268 271 // and for those east of UTC is always positive. 269 return this.date.getTime ZoneOffset() * -60;272 return this.date.getTimezoneOffset() * -60; 270 273 }, 271 274