1
/* Copyright Mihai Bazon, 2002-2005 | www.bazon.net/mishoo
2
* -----------------------------------------------------------
4
* The DHTML Calendar, version 1.0 "It is happening again"
6
* Details and latest version at:
7
* www.dynarch.com/projects/calendar
9
* This script is developed by Dynarch.com. Visit us at www.dynarch.com.
11
* This script is distributed under the GNU Lesser General Public License.
12
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
15
// $Id: /twiki.org/trunk/JSCalendarContrib/pub/TWiki/JSCalendarContrib/calendar.js 15976 2008-09-10T14:55:50.725566Z ArthurClemens $
17
// patched to make the calendar appear in the right position on IE7, using patch
18
// http://sourceforge.net/tracker/index.php?func=detail&aid=1679433&group_id=75569&atid=544287
20
/** The Calendar object constructor. */
21
Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {
23
this.activeDiv = null;
24
this.currentDateEl = null;
25
this.getDateStatus = null;
26
this.getDateToolTip = null;
27
this.getDateText = null;
29
this.onSelected = onSelected || null;
30
this.onClose = onClose || null;
31
this.dragging = false;
35
this.dateFormat = Calendar._TT["DEF_DATE_FORMAT"];
36
this.ttDateFormat = Calendar._TT["TT_DATE_FORMAT"];
38
this.weekNumbers = true;
39
this.firstDayOfWeek = typeof firstDayOfWeek == "number" ? firstDayOfWeek : Calendar._FD; // 0 for Sunday, 1 for Monday, etc.
40
this.showsOtherMonths = false;
41
this.dateStr = dateStr;
43
this.showsTime = false;
46
this.hiliteToday = true;
52
this.firstdayname = null;
54
this.monthsCombo = null;
55
this.yearsCombo = null;
56
this.hilitedMonth = null;
57
this.activeMonth = null;
58
this.hilitedYear = null;
59
this.activeYear = null;
61
this.dateClicked = false;
63
// one-time initializations
64
if (typeof Calendar._SDN == "undefined") {
65
// table of short day names
66
if (typeof Calendar._SDN_len == "undefined")
67
Calendar._SDN_len = 3;
69
for (var i = 8; i > 0;) {
70
ar[--i] = Calendar._DN[i].substr(0, Calendar._SDN_len);
73
// table of short month names
74
if (typeof Calendar._SMN_len == "undefined")
75
Calendar._SMN_len = 3;
77
for (var i = 12; i > 0;) {
78
ar[--i] = Calendar._MN[i].substr(0, Calendar._SMN_len);
86
/// "static", needed for event handlers.
89
/// detect a special case of "web browser"
90
Calendar.is_ie = ( /msie/i.test(navigator.userAgent) &&
91
!/opera/i.test(navigator.userAgent) );
93
Calendar.is_ie5 = ( Calendar.is_ie && /msie 5\.0/i.test(navigator.userAgent) );
94
Calendar.is_ie7up = ( Calendar.is_ie && parseFloat(navigator.userAgent.replace(/.*msie ([0-9]+).*/i, "$1" )) >= 7 );
96
/// detect Opera browser
97
Calendar.is_opera = /opera/i.test(navigator.userAgent);
99
/// detect KHTML-based browsers
100
Calendar.is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
102
// BEGIN: UTILITY FUNCTIONS; beware that these might be moved into a separate
103
// library, at some point.
105
Calendar.getAbsolutePos = function(el) {
107
var is_div = /^div$/i.test(el.tagName);
108
if (is_div && el.scrollLeft)
110
if (is_div && el.scrollTop)
112
var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
113
if (el.offsetParent) {
114
var tmp = this.getAbsolutePos(el.offsetParent);
121
Calendar.isRelated = function (el, evt) {
122
var related = evt.relatedTarget;
125
if (type == "mouseover") {
126
related = evt.fromElement;
127
} else if (type == "mouseout") {
128
related = evt.toElement;
135
related = related.parentNode;
140
Calendar.removeClass = function(el, className) {
141
if (!(el && el.className)) {
144
var cls = el.className.split(" ");
145
var ar = new Array();
146
for (var i = cls.length; i > 0;) {
147
if (cls[--i] != className) {
148
ar[ar.length] = cls[i];
151
el.className = ar.join(" ");
154
Calendar.addClass = function(el, className) {
155
Calendar.removeClass(el, className);
156
el.className += " " + className;
159
// FIXME: the following 2 functions totally suck, are useless and should be replaced immediately.
160
Calendar.getElement = function(ev) {
161
var f = Calendar.is_ie ? window.event.srcElement : ev.currentTarget;
162
while (f.nodeType != 1 || /^div$/i.test(f.tagName))
167
Calendar.getTargetElement = function(ev) {
168
var f = Calendar.is_ie ? window.event.srcElement : ev.target;
169
while (f.nodeType != 1)
174
Calendar.stopEvent = function(ev) {
175
ev || (ev = window.event);
176
if (Calendar.is_ie) {
177
ev.cancelBubble = true;
178
ev.returnValue = false;
181
ev.stopPropagation();
186
Calendar.addEvent = function(el, evname, func) {
187
if (el.attachEvent) { // IE
188
el.attachEvent("on" + evname, func);
189
} else if (el.addEventListener) { // Gecko / W3C
190
el.addEventListener(evname, func, true);
192
el["on" + evname] = func;
196
Calendar.removeEvent = function(el, evname, func) {
197
if (el.detachEvent) { // IE
198
el.detachEvent("on" + evname, func);
199
} else if (el.removeEventListener) { // Gecko / W3C
200
el.removeEventListener(evname, func, true);
202
el["on" + evname] = null;
206
Calendar.createElement = function(type, parent) {
208
if (document.createElementNS) {
209
// use the XHTML namespace; IE won't normally get here unless
210
// _they_ "fix" the DOM2 implementation.
211
el = document.createElementNS("http://www.w3.org/1999/xhtml", type);
213
el = document.createElement(type);
215
if (typeof parent != "undefined") {
216
parent.appendChild(el);
221
// END: UTILITY FUNCTIONS
223
// BEGIN: CALENDAR STATIC FUNCTIONS
225
/** Internal -- adds a set of events to make some element behave like a button. */
226
Calendar._add_evs = function(el) {
228
addEvent(el, "mouseover", dayMouseOver);
229
addEvent(el, "mousedown", dayMouseDown);
230
addEvent(el, "mouseout", dayMouseOut);
232
addEvent(el, "dblclick", dayMouseDblClick);
233
el.setAttribute("unselectable", true);
238
Calendar.findMonth = function(el) {
239
if (typeof el.month != "undefined") {
241
} else if (typeof el.parentNode.month != "undefined") {
242
return el.parentNode;
247
Calendar.findYear = function(el) {
248
if (typeof el.year != "undefined") {
250
} else if (typeof el.parentNode.year != "undefined") {
251
return el.parentNode;
256
Calendar.showMonthsCombo = function () {
257
var cal = Calendar._C;
262
var cd = cal.activeDiv;
263
var mc = cal.monthsCombo;
264
if (cal.hilitedMonth) {
265
Calendar.removeClass(cal.hilitedMonth, "hilite");
267
if (cal.activeMonth) {
268
Calendar.removeClass(cal.activeMonth, "active");
270
var mon = cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()];
271
Calendar.addClass(mon, "active");
272
cal.activeMonth = mon;
276
s.left = cd.offsetLeft + "px";
278
var mcw = mc.offsetWidth;
279
if (typeof mcw == "undefined")
280
// Konqueror brain-dead techniques
282
s.left = (cd.offsetLeft + cd.offsetWidth - mcw) + "px";
284
s.top = (cd.offsetTop + cd.offsetHeight) + "px";
287
Calendar.showYearsCombo = function (fwd) {
288
var cal = Calendar._C;
293
var cd = cal.activeDiv;
294
var yc = cal.yearsCombo;
295
if (cal.hilitedYear) {
296
Calendar.removeClass(cal.hilitedYear, "hilite");
298
if (cal.activeYear) {
299
Calendar.removeClass(cal.activeYear, "active");
301
cal.activeYear = null;
302
var Y = cal.date.getFullYear() + (fwd ? 1 : -1);
303
var yr = yc.firstChild;
305
for (var i = 12; i > 0; --i) {
306
if (Y >= cal.minYear && Y <= cal.maxYear) {
309
yr.style.display = "block";
312
yr.style.display = "none";
315
Y += fwd ? cal.yearStep : -cal.yearStep;
321
s.left = cd.offsetLeft + "px";
323
var ycw = yc.offsetWidth;
324
if (typeof ycw == "undefined")
325
// Konqueror brain-dead techniques
327
s.left = (cd.offsetLeft + cd.offsetWidth - ycw) + "px";
329
s.top = (cd.offsetTop + cd.offsetHeight) + "px";
335
Calendar.tableMouseUp = function(ev) {
336
var cal = Calendar._C;
341
clearTimeout(cal.timeout);
343
var el = cal.activeDiv;
347
var target = Calendar.getTargetElement(ev);
348
ev || (ev = window.event);
349
Calendar.removeClass(el, "active");
350
if (target == el || target.parentNode == el) {
351
Calendar.cellClick(el, ev);
353
var mon = Calendar.findMonth(target);
356
date = new Date(cal.date);
357
if (mon.month != date.getMonth()) {
358
date.setMonth(mon.month);
360
cal.dateClicked = false;
364
var year = Calendar.findYear(target);
366
date = new Date(cal.date);
367
if (year.year != date.getFullYear()) {
368
date.setFullYear(year.year);
370
cal.dateClicked = false;
376
removeEvent(document, "mouseup", tableMouseUp);
377
removeEvent(document, "mouseover", tableMouseOver);
378
removeEvent(document, "mousemove", tableMouseOver);
381
return stopEvent(ev);
385
Calendar.tableMouseOver = function (ev) {
386
var cal = Calendar._C;
390
var el = cal.activeDiv;
391
var target = Calendar.getTargetElement(ev);
392
if (target == el || target.parentNode == el) {
393
Calendar.addClass(el, "hilite active");
394
Calendar.addClass(el.parentNode, "rowhilite");
396
if (typeof el.navtype == "undefined" || (el.navtype != 50 && (el.navtype == 0 || Math.abs(el.navtype) > 2)))
397
Calendar.removeClass(el, "active");
398
Calendar.removeClass(el, "hilite");
399
Calendar.removeClass(el.parentNode, "rowhilite");
401
ev || (ev = window.event);
402
if (el.navtype == 50 && target != el) {
403
var pos = Calendar.getAbsolutePos(el);
404
var w = el.offsetWidth;
415
var range = el._range;
416
var current = el._current;
417
var count = Math.floor(dx / 10) % range.length;
418
for (var i = range.length; --i >= 0;)
419
if (range[i] == current)
424
i = range.length - 1;
425
} else if ( ++i >= range.length )
427
var newval = range[i];
428
el.innerHTML = newval;
432
var mon = Calendar.findMonth(target);
434
if (mon.month != cal.date.getMonth()) {
435
if (cal.hilitedMonth) {
436
Calendar.removeClass(cal.hilitedMonth, "hilite");
438
Calendar.addClass(mon, "hilite");
439
cal.hilitedMonth = mon;
440
} else if (cal.hilitedMonth) {
441
Calendar.removeClass(cal.hilitedMonth, "hilite");
444
if (cal.hilitedMonth) {
445
Calendar.removeClass(cal.hilitedMonth, "hilite");
447
var year = Calendar.findYear(target);
449
if (year.year != cal.date.getFullYear()) {
450
if (cal.hilitedYear) {
451
Calendar.removeClass(cal.hilitedYear, "hilite");
453
Calendar.addClass(year, "hilite");
454
cal.hilitedYear = year;
455
} else if (cal.hilitedYear) {
456
Calendar.removeClass(cal.hilitedYear, "hilite");
458
} else if (cal.hilitedYear) {
459
Calendar.removeClass(cal.hilitedYear, "hilite");
462
return Calendar.stopEvent(ev);
465
Calendar.tableMouseDown = function (ev) {
466
if (Calendar.getTargetElement(ev) == Calendar.getElement(ev)) {
467
return Calendar.stopEvent(ev);
471
Calendar.calDragIt = function (ev) {
472
var cal = Calendar._C;
473
if (!(cal && cal.dragging)) {
478
if (Calendar.is_ie) {
479
posY = window.event.clientY + document.body.scrollTop;
480
posX = window.event.clientX + document.body.scrollLeft;
485
cal.hideShowCovered();
486
var st = cal.element.style;
487
st.left = (posX - cal.xOffs) + "px";
488
st.top = (posY - cal.yOffs) + "px";
489
return Calendar.stopEvent(ev);
492
Calendar.calDragEnd = function (ev) {
493
var cal = Calendar._C;
497
cal.dragging = false;
499
removeEvent(document, "mousemove", calDragIt);
500
removeEvent(document, "mouseup", calDragEnd);
503
cal.hideShowCovered();
506
Calendar.dayMouseDown = function(ev) {
507
var el = Calendar.getElement(ev);
511
var cal = el.calendar;
514
if (el.navtype != 300) with (Calendar) {
515
if (el.navtype == 50) {
516
el._current = el.innerHTML;
517
addEvent(document, "mousemove", tableMouseOver);
519
addEvent(document, Calendar.is_ie5 ? "mousemove" : "mouseover", tableMouseOver);
520
addClass(el, "hilite active");
521
addEvent(document, "mouseup", tableMouseUp);
522
} else if (cal.isPopup) {
525
if (el.navtype == -1 || el.navtype == 1) {
526
if (cal.timeout) clearTimeout(cal.timeout);
527
cal.timeout = setTimeout("Calendar.showMonthsCombo()", 250);
528
} else if (el.navtype == -2 || el.navtype == 2) {
529
if (cal.timeout) clearTimeout(cal.timeout);
530
cal.timeout = setTimeout((el.navtype > 0) ? "Calendar.showYearsCombo(true)" : "Calendar.showYearsCombo(false)", 250);
534
return Calendar.stopEvent(ev);
537
Calendar.dayMouseDblClick = function(ev) {
538
Calendar.cellClick(Calendar.getElement(ev), ev || window.event);
539
if (Calendar.is_ie) {
540
document.selection.empty();
544
Calendar.dayMouseOver = function(ev) {
545
var el = Calendar.getElement(ev);
546
if (Calendar.isRelated(el, ev) || Calendar._C || el.disabled) {
550
if (el.ttip.substr(0, 1) == "_") {
551
el.ttip = el.caldate.print(el.calendar.ttDateFormat) + el.ttip.substr(1);
553
el.calendar.tooltips.innerHTML = el.ttip;
555
if (el.navtype != 300) {
556
Calendar.addClass(el, "hilite");
558
Calendar.addClass(el.parentNode, "rowhilite");
561
return Calendar.stopEvent(ev);
564
Calendar.dayMouseOut = function(ev) {
566
var el = getElement(ev);
567
if (isRelated(el, ev) || _C || el.disabled)
569
removeClass(el, "hilite");
571
removeClass(el.parentNode, "rowhilite");
573
el.calendar.tooltips.innerHTML = _TT["SEL_DATE"];
574
return stopEvent(ev);
579
* A generic "click" handler :) handles all types of buttons defined in this
582
Calendar.cellClick = function(el, ev) {
583
var cal = el.calendar;
587
if (typeof el.navtype == "undefined") {
588
if (cal.currentDateEl) {
589
Calendar.removeClass(cal.currentDateEl, "selected");
590
Calendar.addClass(el, "selected");
591
closing = (cal.currentDateEl == el);
593
cal.currentDateEl = el;
596
cal.date.setDateOnly(el.caldate);
598
var other_month = !(cal.dateClicked = !el.otherMonth);
599
if (!other_month && !cal.currentDateEl)
600
cal._toggleMultipleDate(new Date(date));
602
newdate = !el.disabled;
603
// a date was clicked
605
cal._init(cal.firstDayOfWeek, date);
607
if (el.navtype == 200) {
608
Calendar.removeClass(el, "hilite");
609
cal.callCloseHandler();
612
date = new Date(cal.date);
614
date.setDateOnly(new Date()); // TODAY
615
// unless "today" was clicked, we assume no date was clicked so
616
// the selected handler will know not to close the calenar when
617
// in single-click mode.
618
// cal.dateClicked = (el.navtype == 0);
619
cal.dateClicked = false;
620
var year = date.getFullYear();
621
var mon = date.getMonth();
622
function setMonth(m) {
623
var day = date.getDate();
624
var max = date.getMonthDays(m);
630
switch (el.navtype) {
632
Calendar.removeClass(el, "hilite");
633
var text = Calendar._TT["ABOUT"];
634
if (typeof text != "undefined") {
635
text += cal.showsTime ? Calendar._TT["ABOUT_TIME"] : "";
637
// FIXME: this should be removed as soon as lang files get updated!
638
text = "Help and about box text is not translated into this language.\n" +
639
"If you know this language and you feel generous please update\n" +
640
"the corresponding file in \"lang\" subdir to match calendar-en.js\n" +
641
"and send it back to <mihai_bazon@yahoo.com> to get it into the distribution ;-)\n\n" +
643
"http://dynarch.com/mishoo/calendar.epl\n";
648
if (year > cal.minYear) {
649
date.setFullYear(year - 1);
655
} else if (year-- > cal.minYear) {
656
date.setFullYear(year);
663
} else if (year < cal.maxYear) {
664
date.setFullYear(year + 1);
669
if (year < cal.maxYear) {
670
date.setFullYear(year + 1);
674
cal.setFirstDayOfWeek(el.fdow);
677
var range = el._range;
678
var current = el.innerHTML;
679
for (var i = range.length; --i >= 0;)
680
if (range[i] == current)
682
if (ev && ev.shiftKey) {
684
i = range.length - 1;
685
} else if ( ++i >= range.length )
687
var newval = range[i];
688
el.innerHTML = newval;
692
// TODAY will bring us here
693
if ((typeof cal.getDateStatus == "function") &&
694
cal.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate())) {
699
if (!date.equalsTo(cal.date)) {
702
} else if (el.navtype == 0)
703
newdate = closing = true;
706
ev && cal.callHandler();
709
Calendar.removeClass(el, "hilite");
710
ev && cal.callCloseHandler();
714
// END: CALENDAR STATIC FUNCTIONS
716
// BEGIN: CALENDAR OBJECT FUNCTIONS
719
* This function creates the calendar inside the given parent. If _par is
720
* null than it creates a popup calendar inside the BODY element. If _par is
721
* an element, be it BODY, then it creates a non-popup calendar (still
722
* hidden). Some properties need to be set before calling this function.
724
Calendar.prototype.create = function (_par) {
727
// default parent is the document body, in which case we create
729
parent = document.getElementsByTagName("body")[0];
733
this.isPopup = false;
735
this.date = this.dateStr ? new Date(this.dateStr) : new Date();
737
var table = Calendar.createElement("table");
739
table.cellSpacing = 0;
740
table.cellPadding = 0;
741
table.calendar = this;
742
Calendar.addEvent(table, "mousedown", Calendar.tableMouseDown);
744
var div = Calendar.createElement("div");
746
div.className = "calendar";
748
div.style.position = "absolute";
749
div.style.display = "none";
751
div.appendChild(table);
753
var thead = Calendar.createElement("thead", table);
758
var hh = function (text, cs, navtype) {
759
cell = Calendar.createElement("td", row);
761
cell.className = "button";
762
if (navtype != 0 && Math.abs(navtype) <= 2)
763
cell.className += " nav";
764
Calendar._add_evs(cell);
766
cell.navtype = navtype;
767
cell.innerHTML = "<div unselectable='on'>" + text + "</div>";
771
row = Calendar.createElement("tr", thead);
772
var title_length = 6;
773
(this.isPopup) && --title_length;
774
(this.weekNumbers) && ++title_length;
776
hh("?", 1, 400).ttip = Calendar._TT["INFO"];
777
this.title = hh("", title_length, 300);
778
this.title.className = "title";
780
this.title.ttip = Calendar._TT["DRAG_TO_MOVE"];
781
this.title.style.cursor = "move";
782
hh("×", 1, 200).ttip = Calendar._TT["CLOSE"];
785
row = Calendar.createElement("tr", thead);
786
row.className = "headrow";
788
this._nav_py = hh("«", 1, -2);
789
this._nav_py.ttip = Calendar._TT["PREV_YEAR"];
791
this._nav_pm = hh("‹", 1, -1);
792
this._nav_pm.ttip = Calendar._TT["PREV_MONTH"];
794
this._nav_now = hh(Calendar._TT["TODAY"], this.weekNumbers ? 4 : 3, 0);
795
this._nav_now.ttip = Calendar._TT["GO_TODAY"];
797
this._nav_nm = hh("›", 1, 1);
798
this._nav_nm.ttip = Calendar._TT["NEXT_MONTH"];
800
this._nav_ny = hh("»", 1, 2);
801
this._nav_ny.ttip = Calendar._TT["NEXT_YEAR"];
804
row = Calendar.createElement("tr", thead);
805
row.className = "daynames";
806
if (this.weekNumbers) {
807
cell = Calendar.createElement("td", row);
808
cell.className = "name wn";
809
cell.innerHTML = Calendar._TT["WK"];
811
for (var i = 7; i > 0; --i) {
812
cell = Calendar.createElement("td", row);
815
cell.calendar = this;
816
Calendar._add_evs(cell);
819
this.firstdayname = (this.weekNumbers) ? row.firstChild.nextSibling : row.firstChild;
820
this._displayWeekdays();
822
var tbody = Calendar.createElement("tbody", table);
825
for (i = 6; i > 0; --i) {
826
row = Calendar.createElement("tr", tbody);
827
if (this.weekNumbers) {
828
cell = Calendar.createElement("td", row);
830
for (var j = 7; j > 0; --j) {
831
cell = Calendar.createElement("td", row);
832
cell.calendar = this;
833
Calendar._add_evs(cell);
837
if (this.showsTime) {
838
row = Calendar.createElement("tr", tbody);
839
row.className = "time";
841
cell = Calendar.createElement("td", row);
842
cell.className = "time";
844
cell.innerHTML = Calendar._TT["TIME"] || " ";
846
cell = Calendar.createElement("td", row);
847
cell.className = "time";
848
cell.colSpan = this.weekNumbers ? 4 : 3;
851
function makeTimePart(className, init, range_start, range_end) {
852
var part = Calendar.createElement("span", cell);
853
part.className = className;
854
part.innerHTML = init;
856
part.ttip = Calendar._TT["TIME_PART"];
859
if (typeof range_start != "number")
860
part._range = range_start;
862
for (var i = range_start; i <= range_end; ++i) {
864
if (i < 10 && range_end >= 10) txt = '0' + i;
866
part._range[part._range.length] = txt;
869
Calendar._add_evs(part);
872
var hrs = cal.date.getHours();
873
var mins = cal.date.getMinutes();
874
var t12 = !cal.time24;
876
if (t12 && pm) hrs -= 12;
877
var H = makeTimePart("hour", hrs, t12 ? 1 : 0, t12 ? 12 : 23);
878
var span = Calendar.createElement("span", cell);
879
span.innerHTML = ":";
880
span.className = "colon";
881
var M = makeTimePart("minute", mins, 0, 59);
883
cell = Calendar.createElement("td", row);
884
cell.className = "time";
887
AP = makeTimePart("ampm", pm ? "pm" : "am", ["am", "pm"]);
889
cell.innerHTML = " ";
891
cal.onSetTime = function() {
892
var pm, hrs = this.date.getHours(),
893
mins = this.date.getMinutes();
897
if (hrs == 0) hrs = 12;
898
AP.innerHTML = pm ? "pm" : "am";
900
H.innerHTML = (hrs < 10) ? ("0" + hrs) : hrs;
901
M.innerHTML = (mins < 10) ? ("0" + mins) : mins;
904
cal.onUpdateTime = function() {
905
var date = this.date;
906
var h = parseInt(H.innerHTML, 10);
908
if (/pm/i.test(AP.innerHTML) && h < 12)
910
else if (/am/i.test(AP.innerHTML) && h == 12)
913
var d = date.getDate();
914
var m = date.getMonth();
915
var y = date.getFullYear();
917
date.setMinutes(parseInt(M.innerHTML, 10));
921
this.dateClicked = false;
926
this.onSetTime = this.onUpdateTime = function() {};
929
var tfoot = Calendar.createElement("tfoot", table);
931
row = Calendar.createElement("tr", tfoot);
932
row.className = "footrow";
934
cell = hh(Calendar._TT["SEL_DATE"], this.weekNumbers ? 8 : 7, 300);
935
cell.className = "ttip";
937
cell.ttip = Calendar._TT["DRAG_TO_MOVE"];
938
cell.style.cursor = "move";
940
this.tooltips = cell;
942
div = Calendar.createElement("div", this.element);
943
this.monthsCombo = div;
944
div.className = "combo";
945
for (i = 0; i < Calendar._MN.length; ++i) {
946
var mn = Calendar.createElement("div");
947
mn.className = Calendar.is_ie ? "label-IEfix" : "label";
949
mn.innerHTML = Calendar._SMN[i];
953
div = Calendar.createElement("div", this.element);
954
this.yearsCombo = div;
955
div.className = "combo";
956
for (i = 12; i > 0; --i) {
957
var yr = Calendar.createElement("div");
958
yr.className = Calendar.is_ie ? "label-IEfix" : "label";
962
this._init(this.firstDayOfWeek, this.date);
963
parent.appendChild(this.element);
966
/** keyboard navigation, only for popup calendars */
967
Calendar._keyEvent = function(ev) {
968
var cal = window._dynarch_popupCalendar;
969
if (!cal || cal.multiple)
971
(Calendar.is_ie) && (ev = window.event);
972
var act = (Calendar.is_ie || ev.type == "keypress"),
977
act && Calendar.cellClick(cal._nav_pm);
980
act && Calendar.cellClick(cal._nav_py);
982
case 39: // KEY right
983
act && Calendar.cellClick(cal._nav_nm);
986
act && Calendar.cellClick(cal._nav_ny);
992
case 32: // KEY space (now)
993
Calendar.cellClick(cal._nav_now);
996
act && cal.callCloseHandler();
1000
case 39: // KEY right
1001
case 40: // KEY down
1003
var prev, x, y, ne, el, step;
1004
prev = K == 37 || K == 38;
1005
step = (K == 37 || K == 39) ? 1 : 7;
1006
function setVars() {
1007
el = cal.currentDateEl;
1011
ne = cal.ar_days[y][x];
1013
function prevMonth() {
1014
var date = new Date(cal.date);
1015
date.setDate(date.getDate() - step);
1018
function nextMonth() {
1019
var date = new Date(cal.date);
1020
date.setDate(date.getDate() + step);
1025
case 37: // KEY left
1027
ne = cal.ar_days[y][x];
1036
ne = cal.ar_days[y][x];
1042
case 39: // KEY right
1044
ne = cal.ar_days[y][x];
1051
case 40: // KEY down
1052
if (++y < cal.ar_days.length)
1053
ne = cal.ar_days[y][x];
1064
Calendar.cellClick(ne);
1072
case 13: // KEY enter
1074
Calendar.cellClick(cal.currentDateEl, ev);
1079
return Calendar.stopEvent(ev);
1083
* (RE)Initializes the calendar to the given date and firstDayOfWeek
1085
Calendar.prototype._init = function (firstDayOfWeek, date) {
1086
var today = new Date(),
1087
TY = today.getFullYear(),
1088
TM = today.getMonth(),
1089
TD = today.getDate();
1090
this.table.style.visibility = "hidden";
1091
var year = date.getFullYear();
1092
if (year < this.minYear) {
1093
year = this.minYear;
1094
date.setFullYear(year);
1095
} else if (year > this.maxYear) {
1096
year = this.maxYear;
1097
date.setFullYear(year);
1099
this.firstDayOfWeek = firstDayOfWeek;
1100
this.date = new Date(date);
1101
var month = date.getMonth();
1102
var mday = date.getDate();
1103
var no_days = date.getMonthDays();
1105
// calendar voodoo for computing the first day that would actually be
1106
// displayed in the calendar, even if it's from the previous month.
1107
// WARNING: this is magic. ;-)
1109
var day1 = (date.getDay() - this.firstDayOfWeek) % 7;
1112
date.setDate(-day1);
1113
date.setDate(date.getDate() + 1);
1115
var row = this.tbody.firstChild;
1116
var MN = Calendar._SMN[month];
1117
var ar_days = this.ar_days = new Array();
1118
var weekend = Calendar._TT["WEEKEND"];
1119
var dates = this.multiple ? (this.datesCells = {}) : null;
1120
for (var i = 0; i < 6; ++i, row = row.nextSibling) {
1121
var cell = row.firstChild;
1122
if (this.weekNumbers) {
1123
cell.className = "day wn";
1124
cell.innerHTML = date.getWeekNumber();
1125
cell = cell.nextSibling;
1127
row.className = "daysrow";
1128
var hasdays = false, iday, dpos = ar_days[i] = [];
1129
for (var j = 0; j < 7; ++j, cell = cell.nextSibling, date.setDate(iday + 1)) {
1130
iday = date.getDate();
1131
var wday = date.getDay();
1132
cell.className = "day";
1133
cell.pos = i << 4 | j;
1135
var current_month = (date.getMonth() == month);
1136
if (!current_month) {
1137
if (this.showsOtherMonths) {
1138
cell.className += " othermonth";
1139
cell.otherMonth = true;
1141
cell.className = "emptycell";
1142
cell.innerHTML = " ";
1143
cell.disabled = true;
1147
cell.otherMonth = false;
1150
cell.disabled = false;
1151
cell.innerHTML = this.getDateText ? this.getDateText(date, iday) : iday;
1153
dates[date.print("%Y%m%d")] = cell;
1154
if (this.getDateStatus) {
1155
var status = this.getDateStatus(date, year, month, iday);
1156
if (this.getDateToolTip) {
1157
var toolTip = this.getDateToolTip(date, year, month, iday);
1159
cell.title = toolTip;
1161
if (status === true) {
1162
cell.className += " disabled";
1163
cell.disabled = true;
1165
if (/disabled/i.test(status))
1166
cell.disabled = true;
1167
cell.className += " " + status;
1170
if (!cell.disabled) {
1171
cell.caldate = new Date(date);
1173
if (!this.multiple && current_month
1174
&& iday == mday && this.hiliteToday) {
1175
cell.className += " selected";
1176
this.currentDateEl = cell;
1178
if (date.getFullYear() == TY &&
1179
date.getMonth() == TM &&
1181
cell.className += " today";
1182
cell.ttip += Calendar._TT["PART_TODAY"];
1184
if (weekend.indexOf(wday.toString()) != -1)
1185
cell.className += cell.otherMonth ? " oweekend" : " weekend";
1188
if (!(hasdays || this.showsOtherMonths))
1189
row.className = "emptyrow";
1191
this.title.innerHTML = Calendar._MN[month] + ", " + year;
1193
this.table.style.visibility = "visible";
1194
this._initMultipleDates();
1196
// this.tooltips.innerHTML = "Generated in " + ((new Date()) - today) + " ms";
1199
Calendar.prototype._initMultipleDates = function() {
1200
if (this.multiple) {
1201
for (var i in this.multiple) {
1202
var cell = this.datesCells[i];
1203
var d = this.multiple[i];
1207
cell.className += " selected";
1212
Calendar.prototype._toggleMultipleDate = function(date) {
1213
if (this.multiple) {
1214
var ds = date.print("%Y%m%d");
1215
var cell = this.datesCells[ds];
1217
var d = this.multiple[ds];
1219
Calendar.addClass(cell, "selected");
1220
this.multiple[ds] = date;
1222
Calendar.removeClass(cell, "selected");
1223
delete this.multiple[ds];
1229
Calendar.prototype.setDateToolTipHandler = function (unaryFunction) {
1230
this.getDateToolTip = unaryFunction;
1234
* Calls _init function above for going to a certain date (but only if the
1235
* date is different than the currently selected one).
1237
Calendar.prototype.setDate = function (date) {
1238
if (!date.equalsTo(this.date)) {
1239
this._init(this.firstDayOfWeek, date);
1244
* Refreshes the calendar. Useful if the "disabledHandler" function is
1245
* dynamic, meaning that the list of disabled date can change at runtime.
1246
* Just * call this function if you think that the list of disabled dates
1249
Calendar.prototype.refresh = function () {
1250
this._init(this.firstDayOfWeek, this.date);
1253
/** Modifies the "firstDayOfWeek" parameter (pass 0 for Synday, 1 for Monday, etc.). */
1254
Calendar.prototype.setFirstDayOfWeek = function (firstDayOfWeek) {
1255
this._init(firstDayOfWeek, this.date);
1256
this._displayWeekdays();
1260
* Allows customization of what dates are enabled. The "unaryFunction"
1261
* parameter must be a function object that receives the date (as a JS Date
1262
* object) and returns a boolean value. If the returned value is true then
1263
* the passed date will be marked as disabled.
1265
Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) {
1266
this.getDateStatus = unaryFunction;
1269
/** Customization of allowed year range for the calendar. */
1270
Calendar.prototype.setRange = function (a, z) {
1275
/** Calls the first user handler (selectedHandler). */
1276
Calendar.prototype.callHandler = function () {
1277
if (this.onSelected) {
1278
this.onSelected(this, this.date.print(this.dateFormat));
1282
/** Calls the second user handler (closeHandler). */
1283
Calendar.prototype.callCloseHandler = function () {
1287
this.hideShowCovered();
1290
/** Removes the calendar object from the DOM tree and destroys it. */
1291
Calendar.prototype.destroy = function () {
1292
var el = this.element.parentNode;
1293
el.removeChild(this.element);
1295
window._dynarch_popupCalendar = null;
1299
* Moves the calendar element to a different section in the DOM tree (changes
1302
Calendar.prototype.reparent = function (new_parent) {
1303
var el = this.element;
1304
el.parentNode.removeChild(el);
1305
new_parent.appendChild(el);
1308
// This gets called when the user presses a mouse button anywhere in the
1309
// document, if the calendar is shown. If the click was outside the open
1310
// calendar this function closes it.
1311
Calendar._checkCalendar = function(ev) {
1312
var calendar = window._dynarch_popupCalendar;
1316
var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
1317
for (; el != null && el != calendar.element; el = el.parentNode);
1319
// calls closeHandler which should hide the calendar.
1320
window._dynarch_popupCalendar.callCloseHandler();
1321
return Calendar.stopEvent(ev);
1325
/** Shows the calendar. */
1326
Calendar.prototype.show = function () {
1327
var rows = this.table.getElementsByTagName("tr");
1328
for (var i = rows.length; i > 0;) {
1329
var row = rows[--i];
1330
Calendar.removeClass(row, "rowhilite");
1331
var cells = row.getElementsByTagName("td");
1332
for (var j = cells.length; j > 0;) {
1333
var cell = cells[--j];
1334
Calendar.removeClass(cell, "hilite");
1335
Calendar.removeClass(cell, "active");
1338
this.element.style.display = "block";
1339
this.hidden = false;
1341
window._dynarch_popupCalendar = this;
1342
Calendar.addEvent(document, "keydown", Calendar._keyEvent);
1343
Calendar.addEvent(document, "keypress", Calendar._keyEvent);
1344
Calendar.addEvent(document, "mousedown", Calendar._checkCalendar);
1346
this.hideShowCovered();
1350
* Hides the calendar. Also removes any "hilite" from the class of any TD
1353
Calendar.prototype.hide = function () {
1355
Calendar.removeEvent(document, "keydown", Calendar._keyEvent);
1356
Calendar.removeEvent(document, "keypress", Calendar._keyEvent);
1357
Calendar.removeEvent(document, "mousedown", Calendar._checkCalendar);
1359
this.element.style.display = "none";
1361
this.hideShowCovered();
1365
* Shows the calendar at a given absolute position (beware that, depending on
1366
* the calendar element style -- position property -- this might be relative
1367
* to the parent's containing rectangle).
1369
Calendar.prototype.showAt = function (x, y) {
1370
var s = this.element.style;
1376
/** Shows the calendar near a given element. */
1377
Calendar.prototype.showAtElement = function (el, opts) {
1379
var p = Calendar.getAbsolutePos(el);
1380
if (!opts || typeof opts != "string") {
1381
this.showAt(p.x, p.y + el.offsetHeight);
1384
function fixPosition(box) {
1389
var cp = document.createElement("div");
1391
s.position = "absolute";
1392
s.right = s.bottom = s.width = s.height = "0px";
1393
document.body.appendChild(cp);
1394
var br = Calendar.getAbsolutePos(cp);
1395
document.body.removeChild(cp);
1396
if (Calendar.is_ie && !Calendar.is_ie7up) {
1397
br.y += document.body.scrollTop;
1398
br.x += document.body.scrollLeft;
1400
br.y += window.scrollY;
1401
br.x += window.scrollX;
1403
var tmp = box.x + box.width - br.x;
1404
if (tmp > 0) box.x -= tmp;
1405
tmp = box.y + box.height - br.y;
1406
if (tmp > 0) box.y -= tmp;
1408
this.element.style.display = "block";
1409
Calendar.continuation_for_the_fucking_khtml_browser = function() {
1410
var w = self.element.offsetWidth;
1411
var h = self.element.offsetHeight;
1412
self.element.style.display = "none";
1413
var valign = opts.substr(0, 1);
1415
if (opts.length > 1) {
1416
halign = opts.substr(1, 1);
1418
// vertical alignment
1420
case "T": p.y -= h; break;
1421
case "B": p.y += el.offsetHeight; break;
1422
case "C": p.y += (el.offsetHeight - h) / 2; break;
1423
case "t": p.y += el.offsetHeight - h; break;
1424
case "b": break; // already there
1426
// horizontal alignment
1428
case "L": p.x -= w; break;
1429
case "R": p.x += el.offsetWidth; break;
1430
case "C": p.x += (el.offsetWidth - w) / 2; break;
1431
case "l": p.x += el.offsetWidth - w; break;
1432
case "r": break; // already there
1436
self.monthsCombo.style.display = "none";
1438
self.showAt(p.x, p.y);
1440
if (Calendar.is_khtml)
1441
setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()", 10);
1443
Calendar.continuation_for_the_fucking_khtml_browser();
1446
/** Customizes the date format. */
1447
Calendar.prototype.setDateFormat = function (str) {
1448
this.dateFormat = str;
1451
/** Customizes the tooltip date format. */
1452
Calendar.prototype.setTtDateFormat = function (str) {
1453
this.ttDateFormat = str;
1457
* Tries to identify the date represented in a string. If successful it also
1458
* calls this.setDate which moves the calendar to the given date.
1460
Calendar.prototype.parseDate = function(str, fmt) {
1462
fmt = this.dateFormat;
1463
this.setDate(Date.parseDate(str, fmt));
1466
Calendar.prototype.hideShowCovered = function () {
1467
if (!Calendar.is_ie && !Calendar.is_opera)
1469
function getVisib(obj){
1470
var value = obj.style.visibility;
1472
if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
1473
if (!Calendar.is_khtml)
1474
value = document.defaultView.
1475
getComputedStyle(obj, "").getPropertyValue("visibility");
1478
} else if (obj.currentStyle) { // IE
1479
value = obj.currentStyle.visibility;
1486
var tags = new Array("applet", "iframe", "select");
1487
var el = this.element;
1489
var p = Calendar.getAbsolutePos(el);
1491
var EX2 = el.offsetWidth + EX1;
1493
var EY2 = el.offsetHeight + EY1;
1495
for (var k = tags.length; k > 0; ) {
1496
var ar = document.getElementsByTagName(tags[--k]);
1499
for (var i = ar.length; i > 0;) {
1502
p = Calendar.getAbsolutePos(cc);
1504
var CX2 = cc.offsetWidth + CX1;
1506
var CY2 = cc.offsetHeight + CY1;
1508
if (this.hidden || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
1509
if (!cc.__msh_save_visibility) {
1510
cc.__msh_save_visibility = getVisib(cc);
1512
cc.style.visibility = cc.__msh_save_visibility;
1514
if (!cc.__msh_save_visibility) {
1515
cc.__msh_save_visibility = getVisib(cc);
1517
cc.style.visibility = "hidden";
1523
/** Internal function; it displays the bar with the names of the weekday. */
1524
Calendar.prototype._displayWeekdays = function () {
1525
var fdow = this.firstDayOfWeek;
1526
var cell = this.firstdayname;
1527
var weekend = Calendar._TT["WEEKEND"];
1528
for (var i = 0; i < 7; ++i) {
1529
cell.className = "day name";
1530
var realday = (i + fdow) % 7;
1532
cell.ttip = Calendar._TT["DAY_FIRST"].replace("%s", Calendar._DN[realday]);
1534
cell.calendar = this;
1535
cell.fdow = realday;
1536
Calendar._add_evs(cell);
1538
if (weekend.indexOf(realday.toString()) != -1) {
1539
Calendar.addClass(cell, "weekend");
1541
cell.innerHTML = Calendar._SDN[(i + fdow) % 7];
1542
cell = cell.nextSibling;
1546
/** Internal function. Hides all combo boxes that might be displayed. */
1547
Calendar.prototype._hideCombos = function () {
1548
this.monthsCombo.style.display = "none";
1549
this.yearsCombo.style.display = "none";
1552
/** Internal function. Starts dragging the element. */
1553
Calendar.prototype._dragStart = function (ev) {
1554
if (this.dragging) {
1557
this.dragging = true;
1560
if (Calendar.is_ie) {
1561
posY = window.event.clientY + document.body.scrollTop;
1562
posX = window.event.clientX + document.body.scrollLeft;
1564
posY = ev.clientY + window.scrollY;
1565
posX = ev.clientX + window.scrollX;
1567
var st = this.element.style;
1568
this.xOffs = posX - parseInt(st.left);
1569
this.yOffs = posY - parseInt(st.top);
1571
addEvent(document, "mousemove", calDragIt);
1572
addEvent(document, "mouseup", calDragEnd);
1576
// BEGIN: DATE OBJECT PATCHES
1578
/** Adds the number of days array to the Date object. */
1579
Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
1581
/** Constants used for time computations */
1582
Date.SECOND = 1000 /* milliseconds */;
1583
Date.MINUTE = 60 * Date.SECOND;
1584
Date.HOUR = 60 * Date.MINUTE;
1585
Date.DAY = 24 * Date.HOUR;
1586
Date.WEEK = 7 * Date.DAY;
1588
Date.parseDate = function(str, fmt) {
1589
var today = new Date();
1593
var a = str.split(/\W+/);
1594
var b = fmt.match(/%./g);
1598
for (i = 0; i < a.length; ++i) {
1604
d = parseInt(a[i], 10);
1608
m = parseInt(a[i], 10) - 1;
1613
y = parseInt(a[i], 10);
1614
(y < 100) && (y += (y > 29) ? 1900 : 2000);
1619
for (j = 0; j < 12; ++j) {
1620
if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; }
1628
hr = parseInt(a[i], 10);
1633
if (/pm/i.test(a[i]) && hr < 12)
1635
else if (/am/i.test(a[i]) && hr >= 12)
1640
min = parseInt(a[i], 10);
1644
if (isNaN(y)) y = today.getFullYear();
1645
if (isNaN(m)) m = today.getMonth();
1646
if (isNaN(d)) d = today.getDate();
1647
if (isNaN(hr)) hr = today.getHours();
1648
if (isNaN(min)) min = today.getMinutes();
1649
if (y != 0 && m != -1 && d != 0)
1650
return new Date(y, m, d, hr, min, 0);
1651
y = 0; m = -1; d = 0;
1652
for (i = 0; i < a.length; ++i) {
1653
if (a[i].search(/[a-zA-Z]+/) != -1) {
1655
for (j = 0; j < 12; ++j) {
1656
if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; }
1664
} else if (parseInt(a[i], 10) <= 12 && m == -1) {
1666
} else if (parseInt(a[i], 10) > 31 && y == 0) {
1667
y = parseInt(a[i], 10);
1668
(y < 100) && (y += (y > 29) ? 1900 : 2000);
1669
} else if (d == 0) {
1674
y = today.getFullYear();
1675
if (m != -1 && d != 0)
1676
return new Date(y, m, d, hr, min, 0);
1680
/** Returns the number of days in the current month */
1681
Date.prototype.getMonthDays = function(month) {
1682
var year = this.getFullYear();
1683
if (typeof month == "undefined") {
1684
month = this.getMonth();
1686
if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) {
1689
return Date._MD[month];
1693
/** Returns the number of day in the year. */
1694
Date.prototype.getDayOfYear = function() {
1695
var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
1696
var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
1697
var time = now - then;
1698
return Math.floor(time / Date.DAY);
1701
/** Returns the number of the week in year, as defined in ISO 8601. */
1702
Date.prototype.getWeekNumber = function() {
1703
var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
1704
var DoW = d.getDay();
1705
d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
1706
var ms = d.valueOf(); // GMT
1708
d.setDate(4); // Thu in Week 1
1709
return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
1712
/** Checks date and time equality */
1713
Date.prototype.equalsTo = function(date) {
1714
return ((this.getFullYear() == date.getFullYear()) &&
1715
(this.getMonth() == date.getMonth()) &&
1716
(this.getDate() == date.getDate()) &&
1717
(this.getHours() == date.getHours()) &&
1718
(this.getMinutes() == date.getMinutes()));
1721
/** Set only the year, month, date parts (keep existing time) */
1722
Date.prototype.setDateOnly = function(date) {
1723
var tmp = new Date(date);
1725
this.setFullYear(tmp.getFullYear());
1726
this.setMonth(tmp.getMonth());
1727
this.setDate(tmp.getDate());
1730
/** Prints the date in a string according to the given format. */
1731
Date.prototype.print = function (str) {
1732
var m = this.getMonth();
1733
var d = this.getDate();
1734
var y = this.getFullYear();
1735
var wn = this.getWeekNumber();
1736
var w = this.getDay();
1738
var hr = this.getHours();
1739
var pm = (hr >= 12);
1740
var ir = (pm) ? (hr - 12) : hr;
1741
var dy = this.getDayOfYear();
1744
var min = this.getMinutes();
1745
var sec = this.getSeconds();
1746
s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N]
1747
s["%A"] = Calendar._DN[w]; // full weekday name
1748
s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N]
1749
s["%B"] = Calendar._MN[m]; // full month name
1750
// FIXME: %c : preferred date and time representation for the current locale
1751
s["%C"] = 1 + Math.floor(y / 100); // the century number
1752
s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
1753
s["%e"] = d; // the day of the month (range 1 to 31)
1754
// FIXME: %D : american date style: %m/%d/%y
1755
// FIXME: %E, %F, %G, %g, %h (man strftime)
1756
s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
1757
s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
1758
s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
1759
s["%k"] = hr; // hour, range 0 to 23 (24h format)
1760
s["%l"] = ir; // hour, range 1 to 12 (12h format)
1761
s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
1762
s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
1763
s["%n"] = "\n"; // a newline character
1764
s["%p"] = pm ? "PM" : "AM";
1765
s["%P"] = pm ? "pm" : "am";
1766
// FIXME: %r : the time in am/pm notation %I:%M:%S %p
1767
// FIXME: %R : the time in 24-hour notation %H:%M
1768
s["%s"] = Math.floor(this.getTime() / 1000);
1769
s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
1770
s["%t"] = "\t"; // a tab character
1771
// FIXME: %T : the time in 24-hour notation (%H:%M:%S)
1772
s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
1773
s["%u"] = w + 1; // the day of the week (range 1 to 7, 1 = MON)
1774
s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN)
1775
// FIXME: %x : preferred date representation for the current locale without the time
1776
// FIXME: %X : preferred time representation for the current locale without the date
1777
s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
1778
s["%Y"] = y; // year with the century
1779
s["%%"] = "%"; // a literal '%' character
1782
if (!Calendar.is_ie5 && !Calendar.is_khtml)
1783
return str.replace(re, function (par) { return s[par] || par; });
1785
var a = str.match(re);
1786
for (var i = 0; i < a.length; i++) {
1789
re = new RegExp(a[i], 'g');
1790
str = str.replace(re, tmp);
1797
Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
1798
Date.prototype.setFullYear = function(y) {
1799
var d = new Date(this);
1800
d.__msh_oldSetFullYear(y);
1801
if (d.getMonth() != this.getMonth())
1803
this.__msh_oldSetFullYear(y);
1806
// END: DATE OBJECT PATCHES
1809
// global object that remembers the calendar
1810
window._dynarch_popupCalendar = null;