-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendrical-demo.js
519 lines (497 loc) · 23.9 KB
/
calendrical-demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
/**
* @file Demonstrator for calendar-javascript.
* To be used with suitable calendrical-demo-**.html file.
* contents: global variables, animation routines for the html page, event listeners to follow forms.
* @requires module:calendrical-init.js
* @version M2024-06-31
* @author Louis A. de Fouquières https://github.com/Louis-Aime
* @license MIT 2016-2024
*/
// Character set is UTF-8
/* Version: see details on GitHub
*/
/* Copyright Louis A. de Fouquières https://github.com/Louis-Aime 2016-2024
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sub-license, or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
1. The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
2. Changes with respect to any former version shall be documented.
The software is provided "as is", without warranty of any kind,
express of implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose and non-infringement.
In no event shall the authors of copyright holders be liable for any
claim, damages or other liability, whether in an action of contract,
tort or otherwise, arising from, out of or in connection with the software
or the use or other dealings in the software.
*/
"use strict";
// global const calendrical is initiated as prefix name for user modules.
// global const loadComplete is Promise object that all modules and data are imported.
/** The first date where the Gregorian calendar was enforced, as set by the user. */
var
switchingDate = { day : 15, month : 10, year : 1582 },
/** Array of available custom calendars. */
calendars = [],
/** Index of custom calendar currently used. */
customCalIndex = 0,
/** The date (instant) to be displayed, initially now. */
targetDate = new Date(0),
/** Time zone selector, blank means "system time zone", "UTC" means UTC. These are the only recognised values. */
TZ = "",
/** Computed (real) time zone offset in ms, result may differ from Date.prototype.TZOffset() (in min). */
TZOffset = 0,
/** asked display options for Intl.DateTimeFormat. */
askedOptions,
/** resolved display options for Intl.DateTimeFormat. */
usedOptions,
/** asked display options for ExtDateTimeFormat. */
extAskedOptions,
/** resolved display options for ExtDateTimeFormat. */
extUsedOptions,
/** resolved display options for ExtDateTimeFormat, with the calendar specified by the user. */
cusAskedOptions;
/** Recompute and display all date elements and parameters after a change of targetDate or of display parameters. */
function setDisplay () {
// Set time zone offset at asked date, display parameters.
TZOffset = targetDate.getRealTZmsOffset().valueOf();
let myElement = document.getElementById("sysTZoffset");
myElement.innerHTML = new Intl.NumberFormat().format(targetDate.getTimezoneOffset());
let
systemSign = (TZOffset > 0 ? 1 : -1), // sign is as of JS convention
absoluteRealOffset = systemSign * TZOffset,
absoluteTZmin = Math.floor (absoluteRealOffset / calendrical.TimeUnits.MINUTE_UNIT),
absoluteTZsec = Math.floor ((absoluteRealOffset - absoluteTZmin * calendrical.TimeUnits.MINUTE_UNIT) / calendrical.TimeUnits.SECOND_UNIT);
switch (TZ) {
case "UTC" :
TZOffset = 0; // Set offset to 0, but leave time zone offset on display
case "" :
document.querySelector("#realTZOffset").innerHTML = (systemSign == 1 ? "+ ":"- ") + absoluteTZmin + " min " + absoluteTZsec + " s";
}
// Initiate a representation of local date.
document.custom.calend.value = calendars[customCalIndex].id ;
document.custom.year.value = targetDate.fullYear(TZ); // display fullYear, not just year. fields.year is displayed with era in date string.
document.custom.monthname.value = targetDate.month(TZ); // Display month value in 1..12 range.
document.custom.day.value = targetDate.day(TZ);
document.week.weekyear.value = targetDate.weekYear(TZ); //getElementById("weekyear").innerHTML
document.week.weeknumber.value = targetDate.weekNumber(TZ); //getElementById("weeknum").innerHTML
document.week.weekday.value = targetDate.weekday(TZ); //getElementById("dayownum").innerHTML
document.week.weeksinyear.value = targetDate.weeksInYear(TZ); // getElementById("weeksinyear").innerHTML
try {
document.week.dayofweek.value = // getElementById("dayname").innerHTML
new calendrical.ExtDateTimeFormat
( document.Locale.Elocale.value == "" ? undefined : document.Locale.Elocale.value,
{ weekday : "long", timeZone : TZ == "" ? undefined : TZ }, calendars[customCalIndex] )
.format(targetDate);
}
catch (e) { document.week.dayofweek.value = e.message + "\n" + e.fileName + " line " + e.lineNumber };
// Update system local time fields
document.time.hours.value = targetDate.hours(TZ);
document.time.mins.value = targetDate.minutes(TZ);
document.time.secs.value = targetDate.seconds(TZ);
document.time.ms.value = targetDate.milliseconds(TZ);
// Display UTC date & time in custom calendar, ISO, and Posix number
document.getElementById("dateString").innerHTML = targetDate.toCalString(TZ);
document.getElementById("ISOdatetime").innerHTML = targetDate.toISOString();
document.getElementById("Posixnumber").innerHTML = targetDate.valueOf();
// Display formatted date strings - all with try / catch
document.getElementById("Calendname").innerHTML = usedOptions.calendar;
myElement = document.getElementById("Ustring");
try { myElement.innerHTML = askedOptions.format(targetDate) }
catch (e) { myElement.innerHTML = e.message + "\n" + e.fileName + " line " + e.lineNumber };
myElement = document.getElementById("Xstring");
try { myElement.innerHTML = extAskedOptions.format(targetDate) }
catch (e) { myElement.innerHTML = e.message + "\n" + e.fileName + " line " + e.lineNumber };
document.getElementById("Customname").innerHTML = calendars[customCalIndex].id;
myElement = document.getElementById("Cstring");
try { myElement.innerHTML = cusAskedOptions.format(targetDate) }
catch (e) { myElement.innerHTML = e.message + "\n" + e.fileName + " line " + e.lineNumber };
// Add supplemental computations
document.getElementById("fullyear").innerHTML = targetDate.fullYear(TZ);
document.yeartype.leapyear.value = targetDate.inLeapYear(TZ);
}
/** Recompute all Intl.DateTimeFormat and ExtDateTimeFormat objects after a change in display parameters. */
function compLocalePresentationCalendar() {
let
Locale = document.Locale.Locale.value,
Calendar = document.Locale.Calendar.value,
timeZone = document.Locale.TimeZone.value,
unicodeAskedExtension = document.Locale.UnicodeExt.value,
testDTF;
// modified global variables: askedOptions, usedOptions, extAskedOptions, extUsedOptions, cusAskedOptions;
// Test specified Locale
Locale = Locale == "" ? undefined : Locale;
try {
testDTF = new Intl.DateTimeFormat(Locale);
}
catch (e) {
alert (e.message + "\nCheck locale and extensions" );
return
}
Locale = testDTF.resolvedOptions().locale; // Locale is no longer empty
Locale = Locale.includes("-u-") ? Locale.substring (0,Locale.indexOf("-u-")) : Locale; // Remove Unicode extension
// Add extension
let unicodeExtension = "-u", extendedLocale = Locale;
if (unicodeAskedExtension !== "") unicodeExtension += "-" + unicodeAskedExtension;
if (unicodeExtension !== "-u") extendedLocale += unicodeExtension;
// Add presentation options
let Options = {};
if (document.Locale.LocaleMatcher.value != "") Options.localeMatcher = document.Locale.LocaleMatcher.value;
if (document.Locale.FormatMatcher.value != "") Options.formatMatcher = document.Locale.FormatMatcher.value;
if (document.Locale.TimeZone.value != "") Options.timeZone = document.Locale.TimeZone.value;
if (document.Locale.Calendar.value != "") Options.calendar = document.Locale.Calendar.value;
if (document.Locale.DateStyle.value != "") Options.dateStyle = document.Locale.DateStyle.value;
if (document.Locale.TimeStyle.value != "") Options.timeStyle = document.Locale.TimeStyle.value;
if (document.dateOptions.Weekday.value != "") Options.weekday = document.dateOptions.Weekday.value;
if (document.dateOptions.Day.value != "") Options.day = document.dateOptions.Day.value;
if (document.dateOptions.Month.value != "") Options.month = document.dateOptions.Month.value;
if (document.dateOptions.Year.value != "") Options.year = document.dateOptions.Year.value;
if (document.dateOptions.Era.value != "") Options.era = document.dateOptions.Era.value;
if (document.dateOptions.eraDisplay.value != "") Options.eraDisplay = document.dateOptions.eraDisplay.value;
if (document.timeOptions.Hour.value != "") Options.hour = document.timeOptions.Hour.value;
if (document.timeOptions.Minute.value != "") Options.minute = document.timeOptions.Minute.value;
if (document.timeOptions.Second.value != "") Options.second = document.timeOptions.Second.value;
if (document.timeOptions.Msdigits.value != "") Options.fractionalSecondDigits = document.timeOptions.Msdigits.value;
if (document.timeOptions.TimeZoneName.value != "") Options.timeZoneName = document.timeOptions.TimeZoneName.value;
if (document.timeOptions.Hour12.value != "") Options.hour12 = (document.timeOptions.Hour12.value == "true");
if (document.timeOptions.HourCycle.value != "") Options.hourCycle = document.timeOptions.HourCycle.value;
if (document.timeOptions.AmPm.value != "") Options.dayPeriod = document.timeOptions.AmPm.value;
// Test that Options set is acceptable. If not, display with empty options object
try {
askedOptions = new Intl.DateTimeFormat (extendedLocale, Options);
}
catch (e) {
alert (e.message + "\nCheck options" );
return
}
// Same for ExtDateTimeFormat
try {
extAskedOptions = new calendrical.ExtDateTimeFormat (extendedLocale, Options);
}
catch (e) {
alert (e.message + "\nCheck options for ExtDateTimeFormat" );
return
}
usedOptions = askedOptions.resolvedOptions();
extUsedOptions = extAskedOptions.resolvedOptions();
cusAskedOptions = new calendrical.ExtDateTimeFormat(extendedLocale, Options, calendars[customCalIndex]);
// Display all effective options
document.Locale.Elocale.value = usedOptions.locale;
document.Locale.Enum.value = usedOptions.numberingSystem;
document.Locale.Ecalend.value = usedOptions.calendar;
document.Locale.EtimeZone.value = usedOptions.timeZone;
document.Locale.EdateStyle.value = usedOptions.dateStyle;
document.Locale.EtimeStyle.value = usedOptions.timeStyle ;
document.dateOptions.Eweekday.value = usedOptions.weekday;
document.dateOptions.Eera.value = usedOptions.era;
document.dateOptions.Eyear.value = usedOptions.year;
document.dateOptions.Emonth.value = usedOptions.month;
document.dateOptions.Eday.value = usedOptions.day;
document.timeOptions.EtimeZoneName.value = usedOptions.timeZoneName;
document.timeOptions.Ehour.value = usedOptions.hour;
document.timeOptions.Eminute.value = usedOptions.minute;
document.timeOptions.Esecond.value = usedOptions.second;
document.timeOptions.Emsdigits.value = usedOptions.fractionalSecondDigits;
document.timeOptions.Ehour12.checked = usedOptions.hour12;
document.timeOptions.EhourCycle.value = usedOptions.hourCycle;
document.timeOptions.EAmPm.value = usedOptions.dayPeriod;
// Display all effective options for extended formatter
document.dateOptions.Xweekday.value = extUsedOptions.weekday;
document.dateOptions.Xera.value = extUsedOptions.era;
document.dateOptions.Xyear.value = extUsedOptions.year;
document.dateOptions.Xmonth.value = extUsedOptions.month;
document.dateOptions.Xday.value = extUsedOptions.day;
document.timeOptions.XtimeZoneName.value = extUsedOptions.timeZoneName;
document.timeOptions.Xhour.value = extUsedOptions.hour;
document.timeOptions.Xminute.value = extUsedOptions.minute;
document.timeOptions.Xsecond.value = extUsedOptions.second;
document.timeOptions.Xmsdigits.value = extUsedOptions.fractionalSecondDigits;
document.timeOptions.Xhour12.checked = extUsedOptions.hour12;
document.timeOptions.XhourCycle.value = extUsedOptions.hourCycle;
document.timeOptions.XAmPm.value = extUsedOptions.dayPeriod;
}
/** Set current custom calendar to new value and compute fields. */
function setCalend() {
customCalIndex = calendars.findIndex (item => item.id == document.custom.calend.value); // change custom calendar
targetDate = new calendrical.ExtDate(calendars[customCalIndex], targetDate.valueOf()); // set custom calendar if changed, and set date.
compLocalePresentationCalendar(); // necessary to recompute formatters
}
/** Compute date from field values of current custom calendar. */
function calcCustom() {
var
day = Math.round (document.custom.day.value),
month = Math.round (document.custom.monthname.value),
year = Math.round (document.custom.year.value),
testDate;
// HTML controls that day, month and year are numbers
switch (TZ) {
case "": // Set date object from custom calendar date indication, and with time of day of currently displayed date.
testDate = new calendrical.ExtDate (calendars[customCalIndex], year, month, day, targetDate.getHours(), targetDate.getMinutes(), targetDate.getSeconds(), targetDate.getMilliseconds())
break;
case "UTC" : // // Set date object from custom calendar date indication, and with UTC time of day of currently displayed date.
testDate = new calendrical.ExtDate (calendars[customCalIndex], year, month, day);
testDate.setUTCFullYear (testDate.getFullYear(), testDate.getMonth(), testDate.getDate()); // Ensure passed value are UTC converted
testDate.setUTCHours ( targetDate.getUTCHours(), targetDate.getUTCMinutes(),
targetDate.getUTCSeconds(), targetDate.getUTCMilliseconds() );
break;
}
if (isNaN(testDate.valueOf())) alert ("Out of range")
else {
// Here, no control of date validity, leave JS recompute the date if day of month is out of bounds
targetDate = new calendrical.ExtDate(calendars[customCalIndex], testDate.valueOf()); // set custom calendar if changed, and set date.
}
}
/** Compute date from week field values of current custom calendar. */
function calcWeek() {
var myFields = {
weekYear : Math.round (document.week.weekyear.value),
weekNumber : Math.round (document.week.weeknumber.value),
weekday : Math.round (document.week.weekday.value)
},
testDate = new calendrical.ExtDate(calendars[customCalIndex], targetDate.valueOf());
customCalIndex = calendars.findIndex (item => item.id == document.custom.calend.value); // global variable
switch (TZ) {
case "": // Set date object from custom calendar week date indication, and with time of day of currently displayed date.
myFields.hours = targetDate.getHours();
myFields.minutes = targetDate.getMinutes();
myFields.seconds = targetDate.getSeconds();
myFields.milliseconds = targetDate.getMilliseconds();
break;
case "UTC" : // // Set date object from custom calendar date indication, and with UTC time of day of currently displayed date.
myFields.hours = targetDate.getUTCHours();
myFields.minutes = targetDate.getUTCMinutes();
myFields.seconds = targetDate.getUTCSeconds();
myFields.milliseconds = targetDate.getUTCMilliseconds();
break;
}
try {
testDate.setFromWeekFields( myFields, TZ )
}
catch (e) {
alert (e)
return;
}
if (isNaN(testDate.valueOf())) alert ("Out of range")
else {
// Here, no control of date validity, leave JS recompute the date if day of month is out of bounds
targetDate = new calendrical.ExtDate(calendars[customCalIndex], testDate.valueOf()); // set custom calendar if changed, and set date.
}
}
/** The quantum of decimal days to add or subtract by clicking + or - button. */
var
dayOffset = 1;
// no setDateToToday
/** Change value of dayOffset. */
function changeDayOffset () {
let days = +document.control.shift.value;
if (isNaN(days) || days < 0) {
alert ("Invalid input");
}
else
{
dayOffset = days; // Global variable updated
document.control.shift.value = days; // Confirm changed value
}
}
/** Add or subtract a quantum of days to targetDate.
@param {Number} sign - add if +1, subtract if -1, erroneous if other value.
*/
function setDayOffset (sign=1) {
changeDayOffset(); // Force a valid value in field
let testDate = new Date(targetDate.valueOf());
testDate.setTime (testDate.getTime() + sign * dayOffset * calendrical.TimeUnits.DAY_UNIT);
if (isNaN(testDate.valueOf())) {
alert ("Out of range");
}
else {
targetDate.setTime( testDate.valueOf() );
}
}
/** Set local or UTC time, after global TZ, in same day. */
function calcTime() { // Here the hours are deemed local hours
var hours = Math.round (document.time.hours.value), mins = Math.round (document.time.mins.value),
secs = Math.round (document.time.secs.value), ms = Math.round (document.time.ms.value);
let testDate = new calendrical.ExtDate (calendars[customCalIndex],targetDate.valueOf());
switch (TZ) {
case "" : testDate.setHours(hours, mins, secs, ms); break;
case "UTC" : testDate.setUTCHours(hours, mins, secs, ms); break;
}
if (isNaN(testDate.valueOf())) alert ("Out of range")
else {
targetDate = new calendrical.ExtDate (calendars[customCalIndex],testDate.valueOf());
}
}
/** The quantum of milliseconds to add or subtract by clicking + or - button. */
var addedTime = 60000;
/** Change value of addedTime. */
function changeAddTime() {
let msecs = +document.timeShift.shift.value;
if (isNaN(msecs) || msecs <= 0)
alert ("Invalid input")
else
{
addedTime = msecs; // Global variable updated
document.timeShift.shift.value = msecs; // Confirm changed value
}
}
/** Add or subtract a quantum of time to targetDate.
@param {Number} sign - add if +1, subtract if -1, erroneous if other value.
*/
function addTime (sign = 1) { // addedTime ms is added or subtracted to or from the Timestamp.
changeAddTime(); // Force a valid value in field
let testDate = new Date(targetDate.valueOf());
testDate.setTime (testDate.getTime() + sign * addedTime);
if (isNaN(testDate.valueOf())) alert ("Out of range")
else {
targetDate.setTime( testDate.valueOf() );
}
}
/** Initiate TZ variable (time zone mode) after value in HTML document. */
function getMode() {
TZ = document.TZmode.TZcontrol.value;
}
/** Set a simple UTC hour at same date. The date is computed after TZ value. */
function setUTCHoursFixed (UTChours=0) { // set UTC time to the hours specified.
if (typeof UTChours == undefined) UTChours = document.UTCset.Compute.value;
let testDate = new Date (targetDate.valueOf() - targetDate.getRealTZmsOffset(TZ));
testDate.setUTCHours(UTChours, 0, 0, 0);
if (isNaN(testDate.valueOf())) alert ("Out of range")
else {
targetDate.setTime (testDate.valueOf());
}
}
/** Set date to present instant, with the selected user calendar. */
function setDateToNow(){
targetDate = new calendrical.ExtDate(calendars[customCalIndex]);
}
/**
@namespace window
*/
/** Initialisation function. After page is loaded, global variables are initialised, then event handlers are set.
*@function onload
*@memberof window
*/
window.onload = function () {
// Initial values are taken from forms in page
[ switchingDate.day, switchingDate.month, switchingDate.year ]
= [document.gregorianswitch.day.value, +document.gregorianswitch.month.value, document.gregorianswitch.year.value ]; // computed here for the 'gregorian' calendar.
loadCalendrical.then (() => {
calendars.push (new calendrical.MilesianCalendar ("milesian",calendrical.pldrDOM));
calendars.push (new calendrical.ProlepticGregorianCalendar ("iso_8601"));
calendars.push (new calendrical.JulianCalendar ("julian"));
calendars.push (new calendrical.GregorianCalendar
("gregorian", calendrical.ExtDate.fullUTC(switchingDate.year, switchingDate.month, switchingDate.day), calendrical.pldrDOM));
calendars.push (new calendrical.FrenchRevCalendar ("frenchrev",calendrical.pldrDOM));
calendars.push (new calendrical.Persian33Calendar ("persian33"));
customCalIndex = calendars.findIndex (item => item.id == document.custom.calend.value); // set initial custom calendar - but calendars must exist !
getMode();
compLocalePresentationCalendar(); // set initial formatters to presentation options
calcTime(); // set time as found on page
calcCustom(); // set date as found on page
// setDateToNow(); // this is a variant to those above.
setDisplay(); // initial display of computed target date and time.
});
document.gregorianswitch.addEventListener("submit", function (event) {
event.preventDefault(); // necessary to avoid re-loading with multi-fields forms especially when fields are fetched from event.
let
day = Math.round (event.srcElement.elements.day.value),
month = event.srcElement.elements.month.value,
year = Math.round (event.srcElement.elements.year.value),
testDate = new calendrical.ExtDate (calendars.find(item => item.id == "iso_8601"),calendrical.ExtDate.fullUTC(year, month, day)),
index = calendars.findIndex (item => item.id == "gregorian");
if ( (testDate.valueOf() >= Date.UTC(1582,9,15,0,0,0,0)) && (testDate.day() == day) ) {
calendars[index] = new calendrical.GregorianCalendar("gregorian", testDate.valueOf(), calendrical.pldrDOM);
[document.gregorianswitch.day.value, document.gregorianswitch.month.value, document.gregorianswitch.year.value ]
= [ switchingDate.day, switchingDate.month, switchingDate.year ] = [ day, month, year ];
compLocalePresentationCalendar(); // because we changed one calendar, disseminate change.
if (calendars[customCalIndex].id == "gregorian") targetDate = new calendrical.ExtDate (calendars[index], targetDate.valueOf());
// sweep former gregorian calendar out of current data
}
else {
alert ("Invalid switching date to Gregorian calendar: " + day + '/' + month + '/' + year );
[document.gregorianswitch.day.value, document.gregorianswitch.month.value, document.gregorianswitch.year.value ]
= [ switchingDate.day, switchingDate.month, switchingDate.year ]; // display former approved switching date.
}
setDisplay();
})
document.custom.addEventListener("submit", function (event) {
event.preventDefault();
calcCustom();
setDisplay()
})
document.custom.calend.addEventListener("blur", function (event) {
event.preventDefault();
setCalend();
setDisplay()
})
document.week.addEventListener("submit", function (event) {
event.preventDefault();
calcWeek();
setDisplay()
})
document.control.addEventListener("submit", function (event) {
event.preventDefault();
changeDayOffset()
})
document.control.now.addEventListener("click", function (event) {
setDateToNow();
setDisplay()
})
document.control.minus.addEventListener("click", function (event) {
setDayOffset(-1);
setDisplay()
})
document.control.plus.addEventListener("click", function (event) {
setDayOffset(+1);
setDisplay()
})
document.time.addEventListener("submit", function (event) {
event.preventDefault();
calcTime();
setDisplay()
})
document.timeShift.addEventListener("submit", function (event) {
event.preventDefault();
changeAddTime()
})
document.timeShift.minus.addEventListener("click", function (event) {
addTime(-1);
setDisplay()
})
document.timeShift.plus.addEventListener("click", function (event) {
addTime(+1);
setDisplay()
})
document.TZmode.addEventListener("submit", function (event) {
event.preventDefault();
getMode();
setDisplay()
})
document.getElementById("h0").addEventListener("click", function (event) {
setUTCHoursFixed(0);
setDisplay()
})
document.getElementById("h12").addEventListener("click", function (event) {
setUTCHoursFixed(12);
setDisplay()
})
document.Locale.addEventListener ("submit", function (event) {
event.preventDefault();
compLocalePresentationCalendar();
setDisplay()
})
document.dateOptions.addEventListener ("submit", function (event) {
event.preventDefault();
compLocalePresentationCalendar();
setDisplay();
})
document.timeOptions.addEventListener ("submit", function (event) {
event.preventDefault();
compLocalePresentationCalendar();
setDisplay()
})
}