summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/base/datepicker.js
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts/base/datepicker.js')
-rw-r--r--framework/Web/Javascripts/base/datepicker.js274
1 files changed, 1 insertions, 273 deletions
diff --git a/framework/Web/Javascripts/base/datepicker.js b/framework/Web/Javascripts/base/datepicker.js
index 046a0a4b..68e63168 100644
--- a/framework/Web/Javascripts/base/datepicker.js
+++ b/framework/Web/Javascripts/base/datepicker.js
@@ -3,272 +3,7 @@ Prado.Calendar = Class.create();
Prado.Calendar.Util = Class.create();
Object.extend(Prado.Calendar.Util,
-{
- // utility function to pad a number to a given width
- pad : function(number, X)
- {
- X = (!X ? 2 : X);
- number = ""+number;
- while (number.length < X)
- number = "0" + number;
- return number;
- },
-
- //allow for deprecated formats
- FormatDate : function(date, format)
- {
- if(!isObject(date)) return "";
- if(format.indexOf("%") > -1)
- {
- alert('Please use the new SimpleDateFormat pattern, e.g. yyyy-MM-dd');
- return this.FormatDateDepr(date,format);
- }
- else
- {
- return this.SimpleFormatDate(date, format);
- }
- },
-
- //allow for deprecated format
- ParseDate : function(value, format)
- {
- val=String(value);
- format=String(format);
-
- if(val.length <= 0) return null;
-
- if(format.length <= 0) return new Date(value);
-
- if(format.indexOf("%") > -1)
- return this.ParseDateDepr(value, format);
- else
- return this.SimpleParseDate(value, format);
- },
-
- //deprecated format
- FormatDateDepr : function(date, str)
- {
- var m = date.getMonth();
- var d = date.getDate();
- var y = date.getFullYear();
-
- var s = {};
-
- s["%d"] = this.pad(d); // the day of the month (range 01 to 31)
- s["%e"] = d; // the day of the month (range 1 to 31)
- s["%m"] = this.pad(m+1);
- s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
- s["%Y"] = y; // year with the century
-
- var re = /%./g;
-
- var a = str.match(re);
- for (var i = 0; i < a.length; i++)
- {
- var tmp = s[a[i]];
- if (tmp)
- {
- re = new RegExp(a[i], 'g');
- str = str.replace(re, tmp);
- }
- }
-
- return str;
- },
-
- //deprecated format parser
- ParseDateDepr : function(value, format)
- {
- var y = 0;
- var m = -1;
- var d = 0;
- var a = value.split(/\W+/);
- var b = format.match(/%./g);
- var i = 0, j = 0;
- var hr = 0;
- var min = 0;
- for (i = 0; i < a.length; ++i) {
- if (!a[i])
- continue;
- switch (b[i]) {
- case "%d":
- case "%e":
- d = parseInt(a[i], 10);
- break;
-
- case "%m":
- m = parseInt(a[i], 10) - 1;
- break;
-
- case "%Y":
- case "%y":
- y = parseInt(a[i], 10);
- (y < 100) && (y += (y > 29) ? 1900 : 2000);
- break;
-
- case "%H":
- case "%I":
- case "%k":
- case "%l":
- hr = parseInt(a[i], 10);
- break;
-
- case "%P":
- case "%p":
- if (/pm/i.test(a[i]) && hr < 12)
- hr += 12;
- break;
-
- case "%M":
- min = parseInt(a[i], 10);
- break;
- }
- }
- if (y != 0 && m != -1 && d != 0)
- {
- var date = new Date(y, m, d, hr, min, 0);
- return (isObject(date)
- && y == date.getFullYear()
- && m == date.getMonth()
- && d == date.getDate()) ? date : null;
- }
- return null;
- },
-
- SimpleFormatDate : function(date, format)
- {
- if(!isObject(date)) return "";
- var bits = new Array();
- bits['d'] = date.getDate();
- bits['dd'] = this.pad(date.getDate(),2);
-
- bits['M'] = date.getMonth()+1;
- bits['MM'] = this.pad(date.getMonth()+1,2);
-
- var yearStr = "" + date.getFullYear();
- yearStr = (yearStr.length == 2) ? '19' + yearStr: yearStr;
- bits['yyyy'] = yearStr;
- bits['yy'] = bits['yyyy'].toString().substr(2,2);
-
- // do some funky regexs to replace the format string
- // with the real values
- var frm = new String(format);
- for (var sect in bits)
- {
- var reg = new RegExp("\\b"+sect+"\\b" ,"g");
- frm = frm.replace(reg, bits[sect]);
- }
- return frm;
- },
-
- SimpleParseDate : function(value, format)
- {
- val=String(value);
- format=String(format);
-
- if(val.length <= 0) return null;
-
- if(format.length <= 0) return new Date(value);
-
- var isInteger = function (val)
- {
- var digits="1234567890";
- for (var i=0; i < val.length; i++)
- {
- if (digits.indexOf(val.charAt(i))==-1) { return false; }
- }
- return true;
- };
-
- var getInt = function(str,i,minlength,maxlength)
- {
- for (var x=maxlength; x>=minlength; x--)
- {
- var token=str.substring(i,i+x);
- if (token.length < minlength) { return null; }
- if (isInteger(token)) { return token; }
- }
- return null;
- };
-
- var i_val=0;
- var i_format=0;
- var c="";
- var token="";
- var token2="";
- var x,y;
- var now=new Date();
- var year=now.getFullYear();
- var month=now.getMonth()+1;
- var date=1;
-
- while (i_format < format.length)
- {
- // Get next token from format string
- c=format.charAt(i_format);
- token="";
- while ((format.charAt(i_format)==c) && (i_format < format.length))
- {
- token += format.charAt(i_format++);
- }
-
- // Extract contents of value based on format token
- if (token=="yyyy" || token=="yy" || token=="y")
- {
- if (token=="yyyy") { x=4;y=4; }
- if (token=="yy") { x=2;y=2; }
- if (token=="y") { x=2;y=4; }
- year=getInt(val,i_val,x,y);
- if (year==null) { return null; }
- i_val += year.length;
- if (year.length==2)
- {
- if (year > 70) { year=1900+(year-0); }
- else { year=2000+(year-0); }
- }
- }
-
- else if (token=="MM"||token=="M")
- {
- month=getInt(val,i_val,token.length,2);
- if(month==null||(month<1)||(month>12)){return null;}
- i_val+=month.length;
- }
- else if (token=="dd"||token=="d")
- {
- date=getInt(val,i_val,token.length,2);
- if(date==null||(date<1)||(date>31)){return null;}
- i_val+=date.length;
- }
- else
- {
- if (val.substring(i_val,i_val+token.length)!=token) {return null;}
- else {i_val+=token.length;}
- }
- }
-
- // If there are any trailing characters left in the value, it doesn't match
- if (i_val != val.length) { return null; }
-
- // Is date valid for month?
- if (month==2)
- {
- // Check for leap year
- if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
- if (date > 29){ return null; }
- }
- else { if (date > 28) { return null; } }
- }
-
- if ((month==4)||(month==6)||(month==9)||(month==11))
- {
- if (date > 30) { return null; }
- }
-
- var newdate=new Date(year,month-1,date, 0, 0, 0);
- return newdate;
- },
-
+{
IsLeapYear : function (year)
{
return ((year%4 == 0) && ((year%100 != 0) || (year%400 == 0)));
@@ -288,13 +23,6 @@ Object.extend(Prado.Calendar.Util,
Calendar.LEAP_NUM_DAYS : Calendar.NUM_DAYS;
return a[date.getMonth()] + date.getDate();
},
- ISODate : function(date)
- {
- var y = date.getFullYear();
- var m = this.pad(date.getMonth() + 1);
- var d = this.pad(date.getDate());
- return String(y) + String(m) + String(d);
- },
browser : function()
{