Blame | Last modification | View Log | RSS feed
if(!dojo._hasResource["dojox.date.php"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dojox.date.php"] = true;dojo.provide("dojox.date.php");dojo.require("dojo.date");dojox.date.php.format = function(/*Date*/ date, /*String*/ format, /*Object?*/ overrides){// summary: Get a formatted string for a given date objectvar df = new dojox.date.php.DateFormat(date);return df.format(format, overrides);}dojox.date.php.DateFormat = function(/*Date*/ date){this.date = date;}dojo.extend(dojox.date.php.DateFormat, {weekdays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],weekdays_3: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],months_3: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],monthdays: [31,28,31,30,31,30,31,31,30,31,30,31],format: function(/*String*/ format, /*Object?*/ overrides){// summary: Format the internal date objectvar parts = [];for(var i = 0; i < format.length; i++){var chr = format.charAt(i);if(overrides && typeof overrides[chr] == "function"){parts.push(overrides[chr].call(this));}else if(typeof this[chr] == "function"){parts.push(this[chr]());}else{parts.push(chr);}}return parts.join("");},// Dayd: function(){// summary: Day of the month, 2 digits with leading zerosvar j = this.j();return (j.length == 1) ? "0" + j : j;},D: function(){// summary: A textual representation of a day, three lettersreturn this.weekdays_3[this.date.getDay()];},j: function(){// summary: Day of the month without leading zerosreturn this.date.getDate() + "";},l: function(){// summary: A full textual representation of the day of the weekreturn this.weekdays[this.date.getDay()];},N: function(){// summary: ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0)var w = this.w();return (!w) ? 7 : w;},S: function(){// summary: English ordinal suffix for the day of the month, 2 charactersswitch(this.date.getDate()){case 11: case 12: case 13: return "th";case 1: case 21: case 31: return "st";case 2: case 22: return "nd";case 3: case 23: return "rd";default: return "th";}},w: function(){// summary: Numeric representation of the day of the weekreturn this.date.getDay() + "";},z: function(){// summary: The day of the year (starting from 0)var millis = this.date.getTime() - new Date(this.date.getFullYear(), 0, 1).getTime();return Math.floor(millis/86400000) + "";},// WeekW: function(){// summary: ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)var week;var jan1_w = new Date(this.date.getFullYear(), 0, 1).getDay() + 1;var w = this.date.getDay() + 1;var z = parseInt(this.z());if(z <= (8 - jan1_w) && jan1_w > 4){var last_year = new Date(this.date.getFullYear() - 1, this.date.getMonth(), this.date.getDate());if(jan1_w == 5 || (jan1_w == 6 && dojo.date.isLeapYear(last_year))){week = 53;}else{week = 52;}}else{var i;if(Boolean(this.L())){i = 366;}else{i = 365;}if((i - z) < (4 - w)){week = 1;}else{var j = z + (7 - w) + (jan1_w - 1);week = Math.ceil(j / 7);if(jan1_w > 4){--week;}}}return week;},// MonthF: function(){// summary: A full textual representation of a month, such as January or Marchreturn this.months[this.date.getMonth()];},m: function(){// summary: Numeric representation of a month, with leading zerosvar n = this.n();return (n.length == 1) ? "0" + n : n;},M: function(){// summary: A short textual representation of a month, three lettersreturn months_3[this.date.getMonth()];},n: function(){// summary: Numeric representation of a month, without leading zerosreturn this.date.getMonth() + 1 + "";},t: function(){// summary: Number of days in the given monthreturn (Boolean(this.L()) && this.date.getMonth() == 1) ? 29 : this.monthdays[this.getMonth()];},// YearL: function(){// summary: Whether it's a leap yearreturn (dojo.date.isLeapYear(this.date)) ? "1" : "0";},o: function(){// summary:// ISO-8601 year number. This has the same value as Y, except that if// the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)// TODO: Figure out what this means},Y: function(){// summary: A full numeric representation of a year, 4 digitsreturn this.date.getFullYear() + "";},y: function(){// summary: A two digit representation of a yearreturn this.date.getFullYear.substsring(2, 4);},// Timea: function(){// summary: Lowercase Ante meridiem and Post meridiemreturn this.date.getHours() >= 12 ? "pm" : "am";},b: function(){// summary: Uppercase Ante meridiem and Post meridiemreturn this.a().toUpperCase();},B: function(){// summary:// Swatch Internet time// A day is 1,000 beats. All time is measured from GMT + 1var off = this.date.getTimezoneOffset() + 60;var secs = (this.date.getHours() * 3600) + (this.date.getMinutes() * 60) + this.getSeconds() + (off * 60);var beat = Math.abs(Math.floor(secs / 86.4) % 1000) + "";while(beat.length < 2) beat = "0" + beat;return beat;},g: function(){// summary: 12-hour format of an hour without leading zerosreturn (this.date.getHours() > 12) ? this.date.getHours() - 12 + "" : this.date.getHours() + "";},G: function(){// summary: 24-hour format of an hour without leading zerosreturn this.date.getHours() + "";},h: function(){// summary: 12-hour format of an hour with leading zerosvar g = this.g();return (g.length == 1) ? "0" + g : g;},H: function(){// summary: 24-hour format of an hour with leading zerosvar G = this.G();return (G.length == 1) ? "0" + G : G;},i: function(){// summary: Minutes with leading zerosvar mins = this.date.getMinutes() + "";return (mins.length == 1) ? "0" + mins : mins;},s: function(){// summary: Seconds, with leading zerosvar secs = this.date.getSeconds() + "";return (secs.length == 1) ? "0" + secs : secs;},// Timezonee: function(){// summary: Timezone identifier (added in PHP 5.1.0)return dojo.date.getTimezoneName(this.date);},I: function(){// summary: Whether or not the date is in daylight saving time// TODO: Can dojo.date do this?},O: function(){// summary: Difference to Greenwich time (GMT) in hoursvar off = Math.abs(this.date.getTimezoneOffset());var hours = Math.floor(off / 60) + "";var mins = (off % 60) + "";if(hours.length == 1) hours = "0" + hours;if(mins.length == 1) hours = "0" + mins;return ((this.date.getTimezoneOffset() < 0) ? "+" : "-") + hours + mins;},P: function(){// summary: Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)var O = this.O();return O.substring(0, 2) + ":" + O.substring(2, 4);},T: function(){// summary: Timezone abbreviation// Guess...return this.e().substring(0, 3);},Z: function(){// summary:// Timezone offset in seconds. The offset for timezones west of UTC is always negative,// and for those east of UTC is always positive.return this.date.getTimezoneOffset() * -60;},// Full Date/Timec: function(){// summary: ISO 8601 date (added in PHP 5)return this.Y() + "-" + this.m() + "-" + this.d() + "T" + this.h() + ":" + this.i() + ":" + this.s() + this.P();},r: function(){// summary: RFC 2822 formatted datereturn this.D() + ", " + this.d() + " " + this.M() + " " + this.Y() + " " + this.H() + ":" + this.i() + ":" + this.s() + " " + this.O();},U: function(){// summary: Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)return Math.floor(this.date.getTime() / 1000);}});}