1 String.prototype.trim = function() {
2 return this.replace(/(^\s+|\s+$)/g, '');
5 String.prototype.capitalize = function() {
6 return this.replace(/\w+/g,
8 return ( a.charAt(0).toUpperCase()
9 + a.substr(1).toLowerCase() );
13 String.prototype.decodeEntities = function() {
14 return this.replace(/&#(\d+);/g,
15 function(wholematch, parenmatch1) {
16 return String.fromCharCode(+parenmatch1);
20 String.prototype.asDate = function () {
22 var date = this.split("/");
24 newDate = new Date(date[2], date[1] - 1, date[0]);
26 date = this.split("-");
27 newDate = new Date(date[0], date[1] - 1, date[2]);
33 Date.prototype.sogoDayName = function() {
36 var day = this.getDay();
38 dayName = labels['a2_Sunday'];
39 } else if (day == 1) {
40 dayName = labels['a2_Monday'];
41 } else if (day == 2) {
42 dayName = labels['a2_Tuesday'];
43 } else if (day == 3) {
44 dayName = labels['a2_Wednesday'];
45 } else if (day == 4) {
46 dayName = labels['a2_Thursday'];
47 } else if (day == 5) {
48 dayName = labels['a2_Friday'];
49 } else if (day == 6) {
50 dayName = labels['a2_Saturday'];
56 Date.prototype.daysUpTo = function(otherDate) {
57 var days = new Array();
58 var day1 = this.getTime();
59 var day2 = otherDate.getTime();
61 var nbrDays = Math.floor((day2 - day1) / 86400000) + 1;
62 for (var i = 0; i < nbrDays; i++) {
63 var newDate = new Date();
64 newDate.setTime(day1 + (i * 86400000));
71 Date.prototype.stringWithSeparator = function(separator) {
72 var month = '' + (this.getMonth() + 1);
73 var day = '' + this.getDate();
74 if (month.length == 1)
80 str = (this.getYear() + 1900) + '-' + month + '-' + day;
82 str = day + '/' + month + '/' + (this.getYear() + 1900);
87 Date.prototype.sogoFreeBusyStringWithSeparator = function(separator) {
88 return this.sogoDayName() + ", " + this.stringWithSeparator(separator);