Skip to content

Commit

Permalink
fix: Intl.DateTimeFormat can throw too
Browse files Browse the repository at this point in the history
Signed-off-by: petetnt <pete.a.nykanen@gmail.com>
  • Loading branch information
petetnt committed Oct 11, 2019
1 parent 3d43f1e commit 2260eca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Stats.js
Expand Up @@ -974,7 +974,14 @@ class Stats {
}
if (typeof obj.builtAt === "number") {
const builtAtDate = new Date(obj.builtAt);
let timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
let timeZone = null;

try {
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch (err) {
// disregard the RangeError
}

// Force UTC if runtime timezone could not be detected.
if (!timeZone || timeZone.toLowerCase() === "etc/unknown") {
timeZone = "UTC";
Expand Down

0 comments on commit 2260eca

Please sign in to comment.