// Copyright The IETF Trust 2021, All Rights Reserved /* Timezone support specific to the agenda page To properly handle timezones other than local, needs a method to retrieve the current timezone. Set this by passing a method taking no parameters and returning the current timezone to the set_current_tz_cb() method. This should be done before calling anything else in the file. */ var local_timezone = moment.tz.guess(); // get_current_tz_cb must be overwritten using set_current_tz_cb function get_current_tz_cb() { throw new Error('Tried to get current timezone before callback registered. Use set_current_tz_cb().'); } // Initialize moments window.initialize_moments = function () { var times = $('.time'); $.each(times, function (i, item) { item.start_ts = moment.unix(this.getAttribute("data-start-time")) .utc(); item.end_ts = moment.unix(this.getAttribute("data-end-time")) .utc(); if (this.hasAttribute("weekday")) { item.format = 2; } else { item.format = 1; } if (this.hasAttribute("format")) { item.format = +this.getAttribute("format"); } }); times = $('[data-slot-start-ts]'); $.each(times, function (i, item) { item.slot_start_ts = moment.unix(this.getAttribute("data-slot-start-ts")) .utc(); item.slot_end_ts = moment.unix(this.getAttribute("data-slot-end-ts")) .utc(); }); }; function format_time(t, tz, fmt) { var out; var mtz = window.meeting_timezone; if (mtz == "") { mtz = "UTC"; } switch (fmt) { case 0: out = t.tz(tz) .format('dddd, ') + '' + t.tz(tz) .format('MMMM Do YYYY, ') + '' + t.tz(tz) .format('HH:mm') + '' + t.tz(tz) .format(' Z z') + ''; break; case 1: // Note, this code does not work if the meeting crosses the // year boundary. out = t.tz(tz) .format("HH:mm"); if (+t.tz(tz) .dayOfYear() < +t.tz(mtz) .dayOfYear()) { out = out + " (-1)"; } else if (+t.tz(tz) .dayOfYear() > +t.tz(mtz) .dayOfYear()) { out = out + " (+1)"; } break; case 2: out = t.tz(mtz) .format("dddd, ") .toUpperCase() + t.tz(tz) .format("HH:mm"); if (+t.tz(tz) .dayOfYear() < +t.tz(mtz) .dayOfYear()) { out = out + " (-1)"; } else if (+t.tz(tz) .dayOfYear() > +t.tz(mtz) .dayOfYear()) { out = out + " (+1)"; } break; case 3: out = t.utc() .format("YYYY-MM-DD"); break; case 4: out = t.tz(tz) .format("YYYY-MM-DD HH:mm"); break; case 5: out = t.tz(tz) .format("HH:mm"); break; } return out; } // Format tooltip notice function format_tooltip_notice(start, end) { var notice = ""; if (end.isBefore()) { notice = "Event ended " + end.fromNow(); } else if (start.isAfter()) { notice = "Event will start " + start.fromNow(); } else { notice = "Event started " + start.fromNow() + " and will end " + end.fromNow(); } return '' + notice + ''; } // Format tooltip table function format_tooltip_table(start, end) { var current_timezone = get_current_tz_cb(); var out = '
Session start | Session end | |
---|---|---|
Meeting timezone | ' + format_time(start, window.meeting_timezone, 0) + ' | ' + format_time(end, window.meeting_timezone, 0) + ' |
Local timezone | ' + format_time(start, local_timezone, 0) + ' | ' + format_time(end, local_timezone, 0) + ' |
Selected Timezone | ' + format_time(start, current_timezone, 0) + ' | ' + format_time(end, current_timezone, 0) + ' |
UTC | ' + format_time(start, 'UTC', 0) + ' | ' + format_time(end, 'UTC', 0) + ' |