Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../js/dev
File: jquery.phpdate.js
/*
[0] Fix | Delete
PHP style date() plugin
[1] Fix | Delete
Call in exactly the same way as you do the "date" command in PHP
[2] Fix | Delete
e.g. s = $.PHPDate("l, jS F Y", dtDate);
[3] Fix | Delete
[4] Fix | Delete
License:
[5] Fix | Delete
PHPDate 1.0 jQuery Plugin
[6] Fix | Delete
[7] Fix | Delete
Copyright (c) 2008 Jon Combe (http://joncom.be)
[8] Fix | Delete
[9] Fix | Delete
Permission is hereby granted, free of charge, to any person
[10] Fix | Delete
obtaining a copy of this software and associated documentation
[11] Fix | Delete
files (the "Software"), to deal in the Software without
[12] Fix | Delete
restriction, including without limitation the rights to use,
[13] Fix | Delete
copy, modify, merge, publish, distribute, sublicense, and/or sell
[14] Fix | Delete
copies of the Software, and to permit persons to whom the
[15] Fix | Delete
Software is furnished to do so, subject to the following
[16] Fix | Delete
conditions:
[17] Fix | Delete
[18] Fix | Delete
The above copyright notice and this permission notice shall be
[19] Fix | Delete
included in all copies or substantial portions of the Software.
[20] Fix | Delete
[21] Fix | Delete
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
[22] Fix | Delete
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
[23] Fix | Delete
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
[24] Fix | Delete
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
[25] Fix | Delete
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
[26] Fix | Delete
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
[27] Fix | Delete
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
[28] Fix | Delete
OTHER DEALINGS IN THE SOFTWARE.
[29] Fix | Delete
*/
[30] Fix | Delete
[31] Fix | Delete
(function($) {
[32] Fix | Delete
var aDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
[33] Fix | Delete
var aMonths = ["January","February","March","April","May","June","July","August","September","October","November","December"];
[34] Fix | Delete
[35] Fix | Delete
// main function
[36] Fix | Delete
$.PHPDate = function(sString, dtDate) {
[37] Fix | Delete
var sElement = "";
[38] Fix | Delete
var sOutput = "";
[39] Fix | Delete
[40] Fix | Delete
// we can cheat with "r"...
[41] Fix | Delete
sString = sString.replace(/r/g, "D, j M Y H;i:s O");
[42] Fix | Delete
[43] Fix | Delete
// loop through string
[44] Fix | Delete
for (var i = 0; i < sString.length; i++) {
[45] Fix | Delete
sElement = sString.charAt(i);
[46] Fix | Delete
switch (sElement) {
[47] Fix | Delete
case "a": sElement = AMPM(dtDate.getHours()); break;
[48] Fix | Delete
case "c":
[49] Fix | Delete
sElement = (dtDate.getFullYear() + "-" +
[50] Fix | Delete
AddLeadingZero(dtDate.getMonth()) + "-" +
[51] Fix | Delete
AddLeadingZero(dtDate.getDate()) + "T" +
[52] Fix | Delete
AddLeadingZero(dtDate.getHours()) + ":" +
[53] Fix | Delete
AddLeadingZero(dtDate.getMinutes()) + ":" +
[54] Fix | Delete
AddLeadingZero(dtDate.getSeconds()));
[55] Fix | Delete
var sTemp = dtDate.toString().split(" ")[5];
[56] Fix | Delete
if (sTemp.indexOf("-") > -1) {
[57] Fix | Delete
sElement += sTemp.substr(sTemp.indexOf("-"));
[58] Fix | Delete
} else if (sTemp.indexOf("+") > -1) {
[59] Fix | Delete
sElement += sTemp.substr(sTemp.indexOf("+"));
[60] Fix | Delete
} else {
[61] Fix | Delete
sElement += "+0000";
[62] Fix | Delete
}
[63] Fix | Delete
break;
[64] Fix | Delete
case "d": sElement = AddLeadingZero(dtDate.getDate()); break;
[65] Fix | Delete
case "g": sElement = TwelveHourClock(dtDate.getHours()); break;
[66] Fix | Delete
case "h": sElement = AddLeadingZero(TwelveHourClock(dtDate.getHours())); break;
[67] Fix | Delete
case "i": sElement = AddLeadingZero(dtDate.getMinutes()); break;
[68] Fix | Delete
case "j": sElement = dtDate.getDate(); break;
[69] Fix | Delete
case "l": sElement = aDays[dtDate.getDay()]; break;
[70] Fix | Delete
case "m": sElement = AddLeadingZero(dtDate.getMonth() + 1); break;
[71] Fix | Delete
case "n": sElement = dtDate.getMonth() + 1; break;
[72] Fix | Delete
case "o": (new Date(FirstMonday(dtDate.getFullYear())) > dtDate) ? sElement = (dtDate.getFullYear() - 1) : sElement = dtDate.getFullYear(); break;
[73] Fix | Delete
case "s": sElement = AddLeadingZero(dtDate.getSeconds()); break;
[74] Fix | Delete
case "t":
[75] Fix | Delete
var dtTemp = new Date(dtDate.valueOf());
[76] Fix | Delete
dtTemp.setMonth(dtTemp.getMonth() + 1)
[77] Fix | Delete
dtTemp.setDate(0);
[78] Fix | Delete
sElement = dtTemp.getDate();
[79] Fix | Delete
break;
[80] Fix | Delete
case "u": sElement = dtDate.getMilliseconds(); break;
[81] Fix | Delete
case "w": sElement = dtDate.getDay(); break;
[82] Fix | Delete
case "y": sElement = dtDate.getFullYear().toString().substr(2, 2); break;
[83] Fix | Delete
case "z":
[84] Fix | Delete
var dtFirst = new Date(dtDate.getFullYear(), 0, 1, 0, 0, 0, 0);
[85] Fix | Delete
var dtLast = new Date(dtDate.getFullYear(), dtDate.getMonth(), dtDate.getDate(), 0, 0, 0, 0);
[86] Fix | Delete
sElement = Math.round((dtLast.valueOf() - dtFirst.valueOf()) / 1000 / 60 / 60/ 24);
[87] Fix | Delete
break;
[88] Fix | Delete
case "A": sElement = AMPM(dtDate.getHours()).toUpperCase(); break;
[89] Fix | Delete
case "B":
[90] Fix | Delete
sElement = Math.floor(((dtDate.getHours() * 60 * 60 * 1000) +
[91] Fix | Delete
(dtDate.getMinutes() * 60 * 1000) +
[92] Fix | Delete
(dtDate.getSeconds() * 1000) +
[93] Fix | Delete
(dtDate.getMilliseconds())) / 86400);
[94] Fix | Delete
break;
[95] Fix | Delete
case "D": sElement = aDays[dtDate.getDay()].substr(0, 3); break;
[96] Fix | Delete
case "F": sElement = aMonths[dtDate.getMonth()]; break;
[97] Fix | Delete
case "G": sElement = dtDate.getHours(); break;
[98] Fix | Delete
case "H": sElement = AddLeadingZero(dtDate.getHours()); break;
[99] Fix | Delete
case "I":
[100] Fix | Delete
var dtTempFirst = new Date(dtDate.getFullYear(), 0, 1);
[101] Fix | Delete
var dtTempLast = new Date(dtDate.getFullYear(), dtDate.getMonth(), dtDate.getDate());
[102] Fix | Delete
var iDaysDiff = (dtTempLast.valueOf() - dtTempFirst.valueOf()) / 1000 / 60 / 60 / 24;
[103] Fix | Delete
(iDaysDiff == Math.round(iDaysDiff)) ? sElement = 0 : sElement = 1;
[104] Fix | Delete
break;
[105] Fix | Delete
case "L": ((new Date(dtDate.getFullYear(), 2, 0)).getDate() == 29) ? sElement = 1 : sElement = 0; break;
[106] Fix | Delete
case "M": sElement = aMonths[dtDate.getMonth()].substr(0, 3); break;
[107] Fix | Delete
case "N": (dtDate.getDay() == 0) ? sElement = 7 : sElement = dtDate.getDay(); break;
[108] Fix | Delete
case "O":
[109] Fix | Delete
var sTemp = dtDate.toString().split(" ")[5];
[110] Fix | Delete
if (sTemp.indexOf("-") > -1) {
[111] Fix | Delete
sElement = sTemp.substr(sTemp.indexOf("-"));
[112] Fix | Delete
} else if (sTemp.indexOf("+") > -1) {
[113] Fix | Delete
sElement = sTemp.substr(sTemp.indexOf("+"));
[114] Fix | Delete
} else {
[115] Fix | Delete
sElement = "+0000";
[116] Fix | Delete
}
[117] Fix | Delete
break;
[118] Fix | Delete
case "P":
[119] Fix | Delete
var sTemp = dtDate.toString().split(" ")[5];
[120] Fix | Delete
if (sTemp.indexOf("-") > -1) {
[121] Fix | Delete
var aTemp = sTemp.substr(sTemp.indexOf("-") + 1).split("");
[122] Fix | Delete
sElement = ("-" + aTemp[0] + aTemp[1] + ":" + aTemp[2] + aTemp[3]);
[123] Fix | Delete
} else if (sTemp.indexOf("+") > -1) {
[124] Fix | Delete
var aTemp = sTemp.substr(sTemp.indexOf("+") + 1).split("");
[125] Fix | Delete
sElement = ("+" + aTemp[0] + aTemp[1] + ":" + aTemp[2] + aTemp[3]);
[126] Fix | Delete
} else {
[127] Fix | Delete
sElement = "+00:00";
[128] Fix | Delete
}
[129] Fix | Delete
break;
[130] Fix | Delete
case "S": sElement = DateSuffix(dtDate.getDate()); break;
[131] Fix | Delete
case "T":
[132] Fix | Delete
sElement = dtDate.toString().split(" ")[5];
[133] Fix | Delete
if (sElement.indexOf("+") > -1) {
[134] Fix | Delete
sElement = sElement.substr(0, sElement.indexOf("+"));
[135] Fix | Delete
} else if (sElement.indexOf("-") > -1) {
[136] Fix | Delete
sElement = sElement.substr(0, sElement.indexOf("-"));
[137] Fix | Delete
}
[138] Fix | Delete
break;
[139] Fix | Delete
case "U": sElement = Math.floor(dtDate.getTime() / 1000); break;
[140] Fix | Delete
case "W":
[141] Fix | Delete
var dtTempFirst = new Date(FirstMonday(dtDate.getFullYear()));
[142] Fix | Delete
var dtTempLast = new Date(dtDate.getFullYear(), dtDate.getMonth(), dtDate.getDate());
[143] Fix | Delete
sElement = Math.ceil(Math.round((dtTempLast.valueOf() - dtTempFirst.valueOf()) / 1000 / 60 / 60/ 24) / 7);
[144] Fix | Delete
break;
[145] Fix | Delete
case "Y": sElement = dtDate.getFullYear(); break;
[146] Fix | Delete
case "Z":
[147] Fix | Delete
(dtDate.getTimezoneOffset() < 0) ? sElement = Math.abs(dtDate.getTimezoneOffset() * 60) : sElement = (0 - (dtDate.getTimezoneOffset() * 60));
[148] Fix | Delete
break;
[149] Fix | Delete
}
[150] Fix | Delete
sOutput += sElement.toString();
[151] Fix | Delete
}
[152] Fix | Delete
return sOutput;
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
// add leading zero
[156] Fix | Delete
function AddLeadingZero(iValue) {
[157] Fix | Delete
if (iValue < 10) {
[158] Fix | Delete
iValue = ("0" + iValue);
[159] Fix | Delete
}
[160] Fix | Delete
return iValue;
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
// Ante meridiem and Post meridiem
[164] Fix | Delete
function AMPM(iHours) {
[165] Fix | Delete
if (iHours > 11) {
[166] Fix | Delete
return "pm";
[167] Fix | Delete
} else {
[168] Fix | Delete
return "am";
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
// date suffix
[173] Fix | Delete
function DateSuffix(iDay) {
[174] Fix | Delete
var sSuffix = "th";
[175] Fix | Delete
switch (parseInt(iDay)) {
[176] Fix | Delete
case 1:
[177] Fix | Delete
case 21:
[178] Fix | Delete
case 31:
[179] Fix | Delete
sSuffix = "st";
[180] Fix | Delete
break;
[181] Fix | Delete
case 2:
[182] Fix | Delete
case 22:
[183] Fix | Delete
sSuffix = "nd";
[184] Fix | Delete
break;
[185] Fix | Delete
case 3:
[186] Fix | Delete
case 23:
[187] Fix | Delete
sSuffix = "rd";
[188] Fix | Delete
}
[189] Fix | Delete
return sSuffix;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
// find the first Monday in a given year (for ISO 8601 dates)
[193] Fix | Delete
function FirstMonday(iYear) {
[194] Fix | Delete
var dtTemp = new Date(iYear, 0, 1);
[195] Fix | Delete
while (dtTemp.getDay() != 1) {
[196] Fix | Delete
dtTemp.setDate(dtTemp.getDate() + 1);
[197] Fix | Delete
}
[198] Fix | Delete
return dtTemp.valueOf();
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
// 12-Hour clock
[202] Fix | Delete
function TwelveHourClock(iHours) {
[203] Fix | Delete
if (iHours == 0) {
[204] Fix | Delete
iHours = 24;
[205] Fix | Delete
} else if (iHours > 12) {
[206] Fix | Delete
iHours -= 12;
[207] Fix | Delete
}
[208] Fix | Delete
return iHours;
[209] Fix | Delete
}
[210] Fix | Delete
})(jQuery);
[211] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function