--- js/DateSelector.js 2001/09/25 15:38:04 1.3 +++ js/DateSelector.js 2001/10/30 16:11:28 1.4 @@ -4,7 +4,15 @@ this.sYear = form.year || form.elements[2] || null; this.yBefore = before || 0; this.yAfter = after || 0; - this.BaseDate = date || new Date(); + this.BaseDate = date || null; + if (!this.BaseDate) { + this.BaseDate = new Date(); + this.BaseDate = new Date(this.BaseDate.getYear(), + this.BaseDate.getMonth() + 1, this.BaseDate.getDate()); + } else { + this.BaseDate = new Date(this.BaseDate.getYear(), + this.BaseDate.getMonth() - 1, this.BaseDate.getDate()); + } this.Rebuild = function(d, m, y) { var i, sel; // build day selector @@ -20,7 +28,7 @@ } // build month selector if (this.sMonth != null) { - sel = m || this.sMonth.selectedIndex; + sel = (m - 1) || this.sMonth.selectedIndex; if (sel < 0) sel = this.BaseDate.getMonth(); for (i = 0; i < this.sMonth.options.length; i++) this.sMonth.options[i] = null; @@ -68,13 +76,13 @@ this.Today = function() { var t = new Date(); var d = t.getDate() - 1; - var m = t.getMonth(); + var m = t.getMonth() + 1; var y = this.yBefore; this.Check(d, m, y); + this.Check(d, m, y); this.Rebuild(d, m, y); } this.nDays = null; this.Reset(); - this.Rebuild(); return this; }