【问题标题】:Show 2 Times from Different Time Zones in Week and Day View in Thunderbird Lightning Extension在 Thunderbird Lightning Extension 中的周视图和日视图中显示来自不同时区的 2 次
【发布时间】:2016-12-29 06:39:02
【问题描述】:

Thunderbird Lightning 扩展在 WeekDay 视图的左侧显示时间,如下所示...

我希望时间显示 2 个不同的时区(例如本地时间和太平洋时间),如下所示...

是否有一个配置参数可以做到这一点?是否有另一个扩展可以调整这个?如果没有,我该如何破解 Thunderbird 扩展来做到这一点?

作为参考,Outlook 有这个functionality。此外,answer 还展示了如何破解 Lightning 扩展程序。

【问题讨论】:

    标签: thunderbird thunderbird-addon thunderbird-lightning


    【解决方案1】:

    我不知道有任何现有的附加组件可以做到这一点,但我可以告诉你它是如何完成的。首先创建一个典型的骨架 Thunderbird 扩展,在 Firefox 世界中,如果您正在搜索文档,这被称为“遗留”扩展。它应该包含一个 install.rdf 和一个 chrome.manifest。我假设您选择 view-zones 作为 chrome.manifest 中的标识符。

    接下来,您需要创建一个 CSS 文件,该文件允许您覆盖 calendar-time-bar 绑定。请注意,使用此方法只能有一个扩展覆盖绑定。内容将如下所示:

    calendar-time-bar { 
        -moz-binding: url(chrome://view-zones/content/bindings.xml#calendar-time-bar) !important;
    }
    

    这将使用您在bindings.xml 文件中创建的绑定覆盖时间栏。它扩展了内置时间栏,但在重新布局后添加了一些代码以添加这些额外的标签。 CSS 文件需要在 chrome.manifest 文件中使用style 指令进行引用,并且可以扩展chrome://calendar/skin/calendar-views.css。然后你必须为chrome://view-zones/content/bindings.xml创建xml文件:

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- This Source Code Form is subject to the terms of the Mozilla Public
       - License, v. 2.0. If a copy of the MPL was not distributed with this
       - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
    
    <bindings id="calendar-multiday-view-bindings"
              xmlns="http://www.mozilla.org/xbl"
              xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
              xmlns:xbl="http://www.mozilla.org/xbl">
      <binding id="calendar-time-bar" 
               extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-time-bar">
        <implementation>
          <method name="relayout">
            <body><![CDATA[
              this.__proto__.__proto__.relayout.call(this);
              let XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
              let topbox = document.getAnonymousElementByAttribute(this, "anonid", "topbox");
              for (let box of topbox.childNodes) {
                let timelabel = box.appendChild(document.createElementNS(XUL_NS, "label"));
                timelabel.setAttribute("value", "10:00 PT");
              }
            ]]></body>
          </method>
        </implementation>
      </binding>
    </bindings>
    

    我暂时将标签保留为静态,但您可以考虑一些逻辑,将"10:00 PT" 更改为基于其他标签或actual method 中使用的相同算法的实际时间。您还可以添加类和样式以使其看起来与众不同。

    也就是说,也许您有兴趣将此功能添加到核心 Lightning 中?我认为这将是一个很好的补充。我很确定我们为此打开了一个错误,但我目前找不到它,所以如果您有兴趣,也许您可​​以file a bug,我可以为您提供有关如何设置的更多信息。在这种情况下,只需更改 binding 以显示多个标签并添加用户可见的首选项以便能够选择时区。

    【讨论】:

      【解决方案2】:

      我没有解决一般情况下的问题。我只是让时间显示在当前时区和前一小时显示。就我而言,当前时区是美国山区时间,前一小时最终是美国太平洋时间。

      必须在 Thunderbird 未运行时编辑以下 jar 文件中的文件 calendar-multiday-view.xml

      C:\Users\nreynold.ORADEV\AppData\Roaming\Thunderbird\Profiles\profile\extensions\{e2fda1a4-762b-4020-b5ad-a41df1933103}\chrome.jar

      方法makeTimeBox()必须按照cmets的指示改变:

      function makeTimeBox(timestr, time2str, size) {             // Add time2str parameter
         var box = createXULElement("box");
         box.setAttribute("orient", orient);
         box.setAttribute("align", "left");                       // Add
      
         if (orient == "horizontal") {
            box.setAttribute("width", size);
         } else {
            box.setAttribute("height", size);
         }
      
         var label = createXULElement("label");
         label.setAttribute("class", "calendar-time-bar-label");
         label.setAttribute("value", timestr);
         label.setAttribute("style", "color: #4080C0; font-weight: bold;");   // Replace "align"
      
         box.appendChild(label);
      
         var label = createXULElement("label");                   // Add
         label.setAttribute("class", "calendar-time-bar-label");  // Add
         label.setAttribute("value", time2str);                   // Add
      
         box.appendChild(label);                                  // Add
      
         return box;
      }
      

      makeTimeBox()之后添加如下方法。

      function makeTime(hour) {
         var h = hour % 12;
      
         if (h == 0)
            h = 12;
      
         var s = hour >= 12 ? " pm" : " am";
         var result = h + s;
      
         return result;
      }
      

      删除出现在makeTimeBox()下方几行的以下行

      var formatter = Components.classes["@mozilla.org/intl/scriptabledateformat;1"].
                      getService(Components.interfaces.nsIScriptableDateFormat);
      

      更改以下行...

      var timeString;
      

      ...成为...

      var timeString, time2String;
      

      大约 25 行以下,替换以下行...

      timeString = formatter.FormatTime("",
                                        Components.interfaces.nsIScriptableDateFormat.timeFormatNoSeconds,
                                        theHour, 0, 0);
      box = makeTimeBox(timeString, durPix);
      

      ...成为...

      timeString = makeTime(theHour) + " MT";
      
      ptHour  = theHour - 1;
      ptHour += 23;
      ptHour %= 24;
      ptHour += 1;
      
      time2String = makeTime(ptHour) + " PT";
      box = makeTimeBox(timeString, time2String, durPix);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多