Skip to content

Commit

Permalink
fix: Deal with undetected timeZone in Stats.js
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 8dc440e commit 3d43f1e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Stats.js
Expand Up @@ -974,16 +974,22 @@ class Stats {
}
if (typeof obj.builtAt === "number") {
const builtAtDate = new Date(obj.builtAt);
let timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
// Force UTC if runtime timezone could not be detected.
if (!timeZone || timeZone.toLowerCase() === "etc/unknown") {
timeZone = "UTC";
}
colors.normal("Built at: ");
colors.normal(
builtAtDate.toLocaleDateString(undefined, {
day: "2-digit",
month: "2-digit",
year: "numeric"
year: "numeric",
timeZone
})
);
colors.normal(" ");
colors.bold(builtAtDate.toLocaleTimeString());
colors.bold(builtAtDate.toLocaleTimeString(undefined, { timeZone }));
newline();
}
if (obj.env) {
Expand Down

0 comments on commit 3d43f1e

Please sign in to comment.