Widget:LocalTime

/*<![CDATA[*/ $(function { var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],      months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],      $oldPopover;  $('head').append('');  $.getScript("/extensions/WE/vendor/jQuery.popover/jquery.popover-1.1.2.js", function { $('.weLTime').click(function(event) {     if ($oldPopover) {        $oldPopover.popover('hide');      }      var t = $(this).attr('title');

event.preventDefault; event.stopPropagation;

$oldPopover = $(this); $(this).popover({       trigger: 'none',        title: 'Local time',        content: t      }).popover('show'); return false; }); });  $('.weLTime').each(function {    function hour(d) {      var a = 'AM',          h = d.getHours;      if (h >= 12) {          h = h - 12;          a = 'PM';      }      if (h === 0) {          h = 12;      }      h = h.toString;      return {h: h, a: a};    }    function minute(d) {      var r = d.getMinutes.toString;      if (r.length === 1) {        r = '0' + r;      }      return r;    }

var t = $(this).attr('title'), d = new Date(t), h = hour(d), m = minute(d), ds = days[d.getDay] + ', ' + months[d.getMonth] + ' ' + d.getDate + ' ' + h.h + ':' + m + h.a + ' ' + d.toString.replace(/.*\(([^)]+)\)$/, '$1');   $(this).attr('title', ds);  }); })/*]]>*/

Convert times contained in the title attributes of elements of class weLTime to local time. This is convenient for specifying a meeting time in one time zone and allowing the user to discover her local time.

This widget is intended to be included once on a page containing one or more instances of the   template which makes times wrapped in the appropriate class. When the user hovers over the time, the local time (based on the user's browser time) will be displayed. Clicking on the time causes a small popover window displaying the local time.