Date.getGreeting=function()
{
var d=new Date();
var h=d.getHours();
if(h>4 && h<=12)
return "Bom Dia";
if(h>12 && h<=18)
return "Boa Tarde";
if(h>18 || h<=4)
return "Boa Noite";
}
Date.prototype.getDaysInMonth=function() {
switch (this.getMonth()) {
case 0:
case 2:
case 4:
case 6:
case 7:
case 9:
case 11:
return 31;
case 1:
return (this.getFullYear()%4==0) ? 29 : 28;
default: return 30;
}
}
Date.prototype.getWeekDay = function(lang) {
switch (lang) {
case "pt":
switch (this.getDay()) {
case 1:return "Segunda";
case 2:return "Terça";
case 3:return "Quarta";
case 4:return "Quinta";
case 5:return "Sexta";
case 6:return "Sabado";
default:return "Domingo";
}
break;
default:
switch (this.getDay()) {
case 1:return "Monday";
case 2:return "Tuesday";
case 3:return "Wednesday";
case 4:return "Thursday";
case 5:return "Friday";
case 6:return "Saturday";
default:return "Sunday";
}
break;
}
}
Date.getMonthName = function(lang, month) {
switch (lang) {
case "pt":
var months = [
"Janeiro",
"Fevereiro",
"Março",
"Abril",
"Maio",
"Junho",
"Julho",
"Agosto",
"Setembro",
"Outubro",
"Novembro",
"Dezembro"
];
break;
default:
var months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
break;
}
return months[month];
}
Date.prototype.getMonthNameArray=function() {
return ["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"];
}
Date.prototype.setToPreviousWorkDay=function() {
do {
var wDay=this.getDay();
if (wDay<2) { day-=(wDay+2);
}else {
day--; }
if (day<1) {
var month=this.getMonth()-1;
if (month<0) {
month=11;
this.setFullYear(this.getFullYear()-1);
}
this.setMonth(month);
day=this.getDaysInMonth();
}
this.setDate(day);
wDay=this.getDay();
} while (wDay==0||wDay==6);
return this;
}
Date.prototype.getDateFormat=function( pFormat ) {
var y = this.getFullYear();
var mes = this.getMonth()+1;
var d = this.getDate();
var str = pFormat.replace(/YYYY/, y
).replace(/YY/, new String(this.getFullYear()).slice(1)
).replace(/MM/, (mes < 10 ? "0"+mes : mes)
).replace(/M/, mes
).replace(/DD/, (d < 10 ? "0"+d : d)
).replace(/D/, d
);
if (str.indexOf("h") > -1) {
var h = this.getHours();
var m = this.getMinutes();
var s = this.getSeconds();
var ms = this.getMilliseconds();
str = str.replace(/hh/, (h < 10 ? "0"+h : h)
).replace(/h/, h
).replace(/mm/, (m < 10 ? "0"+m : m)
).replace(/m/, m
).replace(/ss/, (s < 10 ? "0"+s : s)
).replace(/s/, s
).replace(/ms/, ms
);
}
return str;
}
try {
c.control("Date", "loaded");
} catch (e) {
}
