Edit C:\Users\Administrator\Desktop\Back\galaxie - Copy\js\edeal\tools\jquery.datepicker.formatSmartDate.js
(function($) { var extensionMethods = { getSmartDate: function(value, overidedDateFormat, overidedTimeFormat, overidedLocale){ var locale = "fr"; if (overidedLocale) { locale = overidedLocale; } else { try { locale = edContext().locale; } catch(e) {} } var dateFormat = "dd/mm/yy"; if (overidedDateFormat) { dateFormat = overidedDateFormat; } else { try { dateFormat = edContext().dateFormat; } catch(e) {} } var timeFormat = "hh:mm:ss"; if (overidedTimeFormat) { timeFormat = overidedTimeFormat; } else { try { timeFormat = edContext().timeFormat; } catch(e) {} } var daysInWeek = $.datepicker.regional[locale].dayNames; var shortMonthsInYear = $.datepicker.regional[locale].monthNamesShort; var longMonthsInYear = $.datepicker.regional[locale].monthNames; var labelToday = $.datepicker.regional[locale].labelToday; var labelAMomentAgo = $.datepicker.regional[locale].labelAMomentAgo; var labelMinute = $.datepicker.regional[locale].labelMinute; var labelMinutes = $.datepicker.regional[locale].labelMinutes; var labelSecond = $.datepicker.regional[locale].labelSecond; var labelSeconds = $.datepicker.regional[locale].labelSeconds; var labelAgo = $.datepicker.regional[locale].labelAgo; var labelHour = $.datepicker.regional[locale].labelHour; var labelHours = $.datepicker.regional[locale].labelHours; var labelYesterday = $.datepicker.regional[locale].labelYesterday; var labelAt = $.datepicker.regional[locale].labelAt; var labelDay = $.datepicker.regional[locale].labelDay; var labelDays = $.datepicker.regional[locale].labelDays; var labelLastMonth = $.datepicker.regional[locale].labelLastMonth; var labelLast = $.datepicker.regional[locale].labelLast; var labelMonths = $.datepicker.regional[locale].labelMonths; var labelYears = $.datepicker.regional[locale].labelYears; var labelLastYear = $.datepicker.regional[locale].labelLastYear; var labelOClock = $.datepicker.regional[locale].labelOClock; var labelIn = $.datepicker.regional[locale].labelIn; var labelNext = $.datepicker.regional[locale].labelNext; var labelTomorrow = $.datepicker.regional[locale].labelTomorrow; var labelInAFewMoment = $.datepicker.regional[locale].labelInAFewMoment; var labelNextMonth = $.datepicker.regional[locale].labelNextMonth; var labelNextYear = $.datepicker.regional[locale].labelNextYear; //value is a string //check what need to be parsed //this could be just a date, just a time, both of them //if time, check if seconds are presents. If not add them var isTime = false; var isDate = false; var isampm = false; var completeValue = value; var splittedValue = value.split(" "); var parsedDate; var parsedDateTime; var parsedTime; var parsedAmPm = ""; if (value.indexOf("PM") > -1) { parsedAmPm = "PM"; isampm = true; } else { if (value.indexOf("AM") > -1) { parsedAmPm = "AM"; isampm = true; } } var withoutSecondsTimeFormat = timeFormat.replace(":ss", "").replace(":s", ""); for (var i=0; i<splittedValue.length; i++) { var partValue = splittedValue[i]; if (partValue.toUpperCase() != "AM" && partValue.toUpperCase() != "PM") { if (!parsedDate) { parsedDate = $.datepicker.parseDate(dateFormat, partValue); if (parsedDate != null) { isDate = true; } } if (!parsedTime) { if (isampm) { partValue = partValue + " " + parsedAmPm; } parsedTime = $.datepicker.parseTime(timeFormat, partValue); if (!parsedTime) { //perhaps seconds are just missing //try parsing without seconds in timeFormat var withoutSecondsTimeFormat = timeFormat.replace(":ss", "").replace(":s", ""); parsedTime = $.datepicker.parseTime(withoutSecondsTimeFormat, partValue); } if (parsedTime) { isTime = true; } } } } if (isTime || isDate) { //console.log("date detected ? " + isDate); //console.log("time detected ? " + isTime); } else { //console.log(value + " is neither a date, or a time, or a datetime.") return value; } var date = null; var year = null; var month = null; var dayOfMonth = null; var dayOfWeek = null; var time = {}; if (isDate) { year = parsedDate.getFullYear(); month = parsedDate.getMonth() + 1; dayOfMonth = parsedDate.getDate(); dayOfWeek = parsedDate.getDay(); } if (isTime) { time.hour = parsedTime.hour; time.minute = parsedTime.minute; time.second = parsedTime.second; } //compute time label var completeTime = ""; if (isTime) { //if only an hour just display a simple label like "A 15 heures" if (time.minute == "00" || time.minute == "0") { completeTime = labelAt + " " + time.hour + " " + labelOClock; } else { //completeTime = labelAt + " " + time.hour + ":" + time.minute; completeTime = labelAt + " " + $.datepicker.formatTime(withoutSecondsTimeFormat, time); } } if (!isDate) { return completeTime; } //compute date label if (isDate) { var currentDate; var nowDate; if (isTime) { currentDate = new Date(year, month - 1, dayOfMonth, time.hour, time.minute, time.second); nowDate = new Date(); } else { currentDate = new Date(year, month - 1, dayOfMonth, 0, 0, 0); var tempDate = new Date(); nowDate = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(), 0, 0, 0); } var diffInSeconds = $.datepicker.DateDiff.inSeconds(currentDate, nowDate); if (diffInSeconds < 0) { //it's a future date diffInSeconds = $.datepicker.DateDiff.inSeconds(nowDate, currentDate); if (diffInSeconds < 60) { if (isTime) { //return labelInAFewMoment; if (diffInSeconds == 1) { return labelIn + " " + diffInSeconds + " " + labelSecond; } else { return labelIn + " " + diffInSeconds + " " + labelSeconds; } } else { return labelToday; } } else { var diffInMinutes = $.datepicker.DateDiff.inMinutes(nowDate, currentDate); if (diffInMinutes < 60) { if (isTime) { if (diffInMinutes == 1) { return labelIn + " " + diffInMinutes + " " + labelMinute; } else { return labelIn + " " + diffInMinutes + " " + labelMinutes; } } else { return labelToday; } } else { var diffInDays = $.datepicker.DateDiff.inDays(nowDate, currentDate); var diffInHours = $.datepicker.DateDiff.inHours(nowDate, currentDate); if (diffInHours < 24) { if (diffInDays == 0) { if (diffInHours == 1) { if (isTime) { return labelIn + " " + diffInHours + " " + labelHour; } else { return labelToday; } } else { var tomorrow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000); var tomorrowMidnight = new Date(tomorrow.getFullYear(), tomorrow.getMonth(), tomorrow.getDate()); var diffToTomorrow = $.datepicker.DateDiff.inHours(nowDate, tomorrowMidnight); if (diffInHours > diffToTomorrow) { //return labelYesterday + " " + labelAt + " " + time.hour + " " + labelOClock; return labelTomorrow + " " + completeTime; } else { if (isTime) { return labelIn + " " + diffInHours + " " + labelHours; } else { return labelToday; } } } } else { //return labelYesterday + " " + labelAt + " " + time.hour + " " + labelOClock; return labelTomorrow + " " + completeTime; } } else { var diffInMonth = $.datepicker.DateDiff.inMonths(nowDate, currentDate); if (diffInDays == 1) { var tomorrow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000); var tomorrowMidnight = new Date(tomorrow.getFullYear(), tomorrow.getMonth(), tomorrow.getDate()); var diffToTomorrow = $.datepicker.DateDiff.inHours(nowDate, tomorrowMidnight); if (diffInHours < diffToTomorrow + 24) { //return labelYesterday + " " + labelAt + " " + time.hour + " " + labelOClock; return labelTomorrow + " " + completeTime; } else { return daysInWeek[currentDate.getDay()] + " " + labelNext + " " + completeTime; } } else { if (diffInMonth == 0) { if (diffInDays < 7) { if (locale == "en") { return labelNext + " " + daysInWeek[currentDate.getDay()] + " " + completeTime; } else { return daysInWeek[currentDate.getDay()] + " " + labelNext + " " + completeTime; } } else { return labelIn + " " + diffInDays + " " + labelDays; } } else { if (diffInMonth == 1) { return labelNextMonth; } else { var diffInYears = $.datepicker.DateDiff.inYears(nowDate, currentDate); if (diffInYears == 0) { if (diffInMonth < 12) { if (locale == "en") { return labelNext + " " + longMonthsInYear[currentDate.getMonth()]; } else { return longMonthsInYear[currentDate.getMonth()] + " " + labelNext; } } else { return labelIn + " " + diffInMonth + " " + labelMonths; } } else { if (diffInYears == 1) { return labelNextYear; } else { return labelIn + " " + diffInYears + " " + labelYears; } } } } } } } } } else { //it's a past date if (diffInSeconds < 60) { if (isTime) { return labelAMomentAgo; } else { return labelToday; } } else { var diffInMinutes = $.datepicker.DateDiff.inMinutes(currentDate, nowDate); if (diffInMinutes < 60) { if (isTime) { if (diffInMinutes == 1) { if (locale == "en") { return diffInMinutes + " " + labelMinute + " " + labelAgo; } else { return labelAgo + " " + diffInMinutes + " " + labelMinute; } } else { if (locale == "en") { return diffInMinutes + " " + labelMinutes + " " + labelAgo; } else { return labelAgo + " " + diffInMinutes + " " + labelMinutes; } } } else { return labelToday; } } else { var diffInDays = $.datepicker.DateDiff.inDays(currentDate, nowDate); var diffInHours = $.datepicker.DateDiff.inHours(currentDate, nowDate); if (diffInHours < 24) { if (diffInDays == 0) { if (diffInHours == 1) { if (isTime) { if (locale == "en") { return diffInHours + " " + labelHour + " " + labelAgo; } else { return labelAgo + " " + diffInHours + " " + labelHours; } } else { return labelToday; } } else { var midnightDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate()); var diffSinceMidnight = $.datepicker.DateDiff.inHours(midnightDate, nowDate); if (diffInHours > diffSinceMidnight) { //return labelYesterday + " " + labelAt + " " + time.hour + " " + labelOClock; return labelYesterday + " " + completeTime; } else { if (isTime) { if (locale == "en") { return diffInHours + " " + labelHours + " " + labelAgo; } else { return labelAgo + " " + diffInHours + " " + labelHours; } } else { return labelToday; } } } } else { //return labelYesterday + " " + labelAt + " " + time.hour + " " + labelOClock; return labelYesterday + " " + completeTime; } } else { var diffInMonth = $.datepicker.DateDiff.inMonths(currentDate, nowDate); if (diffInDays == 1) { //return labelYesterday + " " + labelAt + " " + time.hour + " " + labelOClock; return labelYesterday + " " + completeTime; } else { if (diffInMonth == 0) { if (diffInDays < 7) { //return daysInWeek[currentDate.getDay()] + " " + labelAt + " " + time.hour + " " + labelOClock; if (locale == "en") { return labelLast + " " + daysInWeek[currentDate.getDay()] + " " + completeTime; } else { return daysInWeek[currentDate.getDay()] + " " + labelLast + " " + completeTime; } } else { if (locale == "en") { return diffInDays + " " + labelDays + " " + labelAgo; } else { return labelAgo + " " + diffInDays + " " + labelDays; } } } else { if (diffInMonth == 1) { return labelLastMonth; } else { var diffInYears = $.datepicker.DateDiff.inYears(currentDate, nowDate); if (diffInYears == 0) { if (diffInMonth < 12) { if (locale == "en") { return labelLast + " " + longMonthsInYear[currentDate.getMonth()]; } else { return longMonthsInYear[currentDate.getMonth()] + " " + labelLast; } } else { if (locale == "en") { return diffInMonth + " " + labelMonths + " " + labelAgo; } else { return labelAgo + " " + diffInMonth + " " + labelMonths; } } } else { if (diffInYears == 1) { return labelLastYear; } else { if (locale == "en") { return diffInYears + " " + labelYears + " " + labelAgo; } else { return labelAgo + " " + diffInYears + " " + labelYears; } } } } } } } } } } } } }; $.extend(true, $.datepicker, extensionMethods); })(jQuery); (function($) { var extensionMethods = { DateDiff : { inSeconds: function(d1, d2) { var t2 = d2.getTime(); var t1 = d1.getTime(); return parseInt((t2-t1)/(1000)); }, inMinutes: function(d1, d2) { var t2 = d2.getTime(); var t1 = d1.getTime(); return parseInt((t2-t1)/(60*1000)); }, inHours: function(d1, d2) { var t2 = d2.getTime(); var t1 = d1.getTime(); return parseInt((t2-t1)/(3600*1000)); }, inDays: function(d1, d2) { var t2 = d2.getTime(); var t1 = d1.getTime(); return parseInt((t2-t1)/(24*3600*1000)); }, inWeeks: function(d1, d2) { var t2 = d2.getTime(); var t1 = d1.getTime(); return parseInt((t2-t1)/(24*3600*1000*7)); }, inMonths: function(d1, d2) { var d1Y = d1.getFullYear(); var d2Y = d2.getFullYear(); var d1M = d1.getMonth(); var d2M = d2.getMonth(); return (d2M+12*d2Y)-(d1M+12*d1Y); }, inYears: function(d1, d2) { return d2.getFullYear()-d1.getFullYear(); } } }; $.extend(true, $.datepicker, extensionMethods); })(jQuery);
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de