Skip to content

Commit f523293

Browse files
committed
fix: Only add timeZone if toLocaleString throws with initial timeZone
Signed-off-by: petetnt <[email protected]>
1 parent 42407cb commit f523293

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/Stats.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -974,18 +974,15 @@ class Stats {
974974
}
975975
if (typeof obj.builtAt === "number") {
976976
const builtAtDate = new Date(obj.builtAt);
977-
let timeZone = null;
977+
let timeZone;
978978

979979
try {
980-
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
980+
builtAtDate.toLocaleTimeString();
981981
} catch (err) {
982-
// disregard the RangeError
983-
}
984-
985-
// Force UTC if runtime timezone could not be detected.
986-
if (!timeZone || timeZone.toLowerCase() === "etc/unknown") {
982+
// Force UTC if runtime timezone is unsupported
987983
timeZone = "UTC";
988984
}
985+
989986
colors.normal("Built at: ");
990987
colors.normal(
991988
builtAtDate.toLocaleDateString(undefined, {

0 commit comments

Comments
 (0)