rbrindley: branch rbrindley/astman_revamp r4606 - /team/rbrindley/astman_reva...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Wed Mar 11 09:50:06 CDT 2009
Author: rbrindley
Date: Wed Mar 11 09:50:02 2009
New Revision: 4606
URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4606
Log:
- implemented String.prototype.valiDate (das riight) in js/object.customs.js, replacing ti_miscFunctions.check_ifDatesAreValid in js/timeintervals.js
Modified:
team/rbrindley/astman_revamp/config/js/object.customs.js
Modified: team/rbrindley/astman_revamp/config/js/object.customs.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/object.customs.js?view=diff&rev=4606&r1=4605&r2=4606
==============================================================================
--- team/rbrindley/astman_revamp/config/js/object.customs.js (original)
+++ team/rbrindley/astman_revamp/config/js/object.customs.js Wed Mar 11 09:50:02 2009
@@ -324,6 +324,40 @@
return this.split(k).join('');
};
+/**
+ * Validates Dates
+ * validates that this string is of formats: '05' or '02-18'
+ * @return boolean
+ */
+String.prototype.valiDate = function() { /* get it?? */
+ if (this.length > 5) {
+ /* max format length is '12-31', 5 chars */
+ return false;
+ } else if (this.length > 2 && this[2] != '-') {
+ return false;
+ }
+
+ var splits = this.split('-');
+
+ if (splits.length > 1) {
+ /* when parsing dates, make sure you are using base 10
+ * parseInt likes to think in octals when numbers
+ * have leading zeros like, 05 */
+ var month = parseInt(splits[0], 10);
+ var day = parseInt(splits[1], 10);
+ } else {
+ var day = parseInt(this, 10);
+ }
+
+ if (month && (month > 12 || month < 0)) {
+ return false;
+ }
+
+ if (day && (day < 0 || day > 31)) {
+ return false;
+ }
+};
+
Number.prototype.addZero = function(){
return ( this < 10)? "0" + String(this) : String(this);
More information about the asterisk-gui-commits
mailing list