Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/utils.js

Issue 29459562: Issue 5278 - Improved date formatting approach, in particular fixing broken formatting in 32-bit Li… (Closed) Base URL: https://hg.adblockplus.org/adblockplus
Left Patch Set: Created June 8, 2017, 8 a.m.
Right Patch Set: Use default locale after all Created June 8, 2017, 8:47 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 finally 239 finally
240 { 240 {
241 if (stream) 241 if (stream)
242 stream.close(); 242 stream.close();
243 } 243 }
244 }, 244 },
245 245
246 /** 246 /**
247 * Formats a unix time according to user's locale. 247 * Formats a unix time according to user's locale.
248 * @param {Integer} time unix time in milliseconds 248 * @param {Integer} time unix time in milliseconds
249 * @return {String} formatted date and time 249 * @return {String} formatted date and time
Wladimir Palant 2017/06/08 08:13:02 Yes, I am aware of this not being entirely correct
250 */ 250 */
251 formatTime: function(time) 251 formatTime: function(time)
252 { 252 {
253 try 253 try
254 { 254 {
255 return Utils.dateFormatter.format(time); 255 return Utils.dateFormatter.format(time);
Wladimir Palant 2017/06/08 08:13:01 The MDN documentation doesn't define the parameter
256 } 256 }
257 catch(e) 257 catch(e)
258 { 258 {
259 // Make sure to return even on errors 259 // Make sure to return even on errors
260 Cu.reportError(e); 260 Cu.reportError(e);
261 return ""; 261 return "";
262 } 262 }
263 }, 263 },
264 264
265 /** 265 /**
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 XPCOMUtils.defineLazyServiceGetter(Utils, "versionComparator", "@mozilla.org/xpc om/version-comparator;1", "nsIVersionComparator"); 554 XPCOMUtils.defineLazyServiceGetter(Utils, "versionComparator", "@mozilla.org/xpc om/version-comparator;1", "nsIVersionComparator");
555 XPCOMUtils.defineLazyServiceGetter(Utils, "windowMediator", "@mozilla.org/appshe ll/window-mediator;1", "nsIWindowMediator"); 555 XPCOMUtils.defineLazyServiceGetter(Utils, "windowMediator", "@mozilla.org/appshe ll/window-mediator;1", "nsIWindowMediator");
556 XPCOMUtils.defineLazyServiceGetter(Utils, "windowWatcher", "@mozilla.org/embedco mp/window-watcher;1", "nsIWindowWatcher"); 556 XPCOMUtils.defineLazyServiceGetter(Utils, "windowWatcher", "@mozilla.org/embedco mp/window-watcher;1", "nsIWindowWatcher");
557 XPCOMUtils.defineLazyServiceGetter(Utils, "chromeRegistry", "@mozilla.org/chrome /chrome-registry;1", "nsIXULChromeRegistry"); 557 XPCOMUtils.defineLazyServiceGetter(Utils, "chromeRegistry", "@mozilla.org/chrome /chrome-registry;1", "nsIXULChromeRegistry");
558 XPCOMUtils.defineLazyServiceGetter(Utils, "systemPrincipal", "@mozilla.org/syste mprincipal;1", "nsIPrincipal"); 558 XPCOMUtils.defineLazyServiceGetter(Utils, "systemPrincipal", "@mozilla.org/syste mprincipal;1", "nsIPrincipal");
559 XPCOMUtils.defineLazyServiceGetter(Utils, "httpProtocol", "@mozilla.org/network/ protocol;1?name=http", "nsIHttpProtocolHandler"); 559 XPCOMUtils.defineLazyServiceGetter(Utils, "httpProtocol", "@mozilla.org/network/ protocol;1?name=http", "nsIHttpProtocolHandler");
560 XPCOMUtils.defineLazyServiceGetter(Utils, "clipboard", "@mozilla.org/widget/clip board;1", "nsIClipboard"); 560 XPCOMUtils.defineLazyServiceGetter(Utils, "clipboard", "@mozilla.org/widget/clip board;1", "nsIClipboard");
561 XPCOMUtils.defineLazyServiceGetter(Utils, "clipboardHelper", "@mozilla.org/widge t/clipboardhelper;1", "nsIClipboardHelper"); 561 XPCOMUtils.defineLazyServiceGetter(Utils, "clipboardHelper", "@mozilla.org/widge t/clipboardhelper;1", "nsIClipboardHelper");
562 XPCOMUtils.defineLazyGetter(Utils, "dateFormatter", function() 562 XPCOMUtils.defineLazyGetter(Utils, "dateFormatter", function()
563 { 563 {
564 return new Intl.DateTimeFormat(Utils.appLocale, { 564 return new Intl.DateTimeFormat(undefined, {
Wladimir Palant 2017/06/08 08:13:01 Originally, I meant to pass undefined as first par
Wladimir Palant 2017/06/08 08:49:02 After looking a bit more into this, the inconsiste
565 year: "numeric", 565 year: "numeric",
566 month: "numeric", 566 month: "numeric",
567 day: "numeric", 567 day: "numeric",
568 hour: "numeric", 568 hour: "numeric",
569 minute: "numeric" 569 minute: "numeric"
570 }); 570 });
571 }); 571 });
572 XPCOMUtils.defineLazyGetter(Utils, "crypto", function() 572 XPCOMUtils.defineLazyGetter(Utils, "crypto", function()
573 { 573 {
574 try 574 try
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 Cu.reportError(e); 735 Cu.reportError(e);
736 // Expected, ctypes isn't supported in Gecko 1.9.2 736 // Expected, ctypes isn't supported in Gecko 1.9.2
737 return null; 737 return null;
738 } 738 }
739 }); 739 });
740 740
741 if ("@mozilla.org/messenger/headerparser;1" in Cc) 741 if ("@mozilla.org/messenger/headerparser;1" in Cc)
742 XPCOMUtils.defineLazyServiceGetter(Utils, "headerParser", "@mozilla.org/messen ger/headerparser;1", "nsIMsgHeaderParser"); 742 XPCOMUtils.defineLazyServiceGetter(Utils, "headerParser", "@mozilla.org/messen ger/headerparser;1", "nsIMsgHeaderParser");
743 else 743 else
744 Utils.headerParser = null; 744 Utils.headerParser = null;
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld