Skip to content

Commit

Permalink
Merge pull request #9821 from petetnt/fix-stats-issue
Browse files Browse the repository at this point in the history
fix: Only add timeZone if toLocaleString throws with initial timeZone
  • Loading branch information
sokra committed Oct 15, 2019
2 parents b3d7636 + 009e47c commit e928727
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/Stats.js
Expand Up @@ -974,18 +974,15 @@ class Stats {
}
if (typeof obj.builtAt === "number") {
const builtAtDate = new Date(obj.builtAt);
let timeZone = null;
let timeZone = undefined;

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

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

colors.normal("Built at: ");
colors.normal(
builtAtDate.toLocaleDateString(undefined, {
Expand Down

0 comments on commit e928727

Please sign in to comment.