]> git.kaiwu.me - quickjs.git/commitdiff
show readable representation of Date objects in repl
authorCharlie Gordon <github@chqrlie.org>
Sun, 25 Feb 2024 21:53:29 +0000 (22:53 +0100)
committerCharlie Gordon <github@chqrlie.org>
Sun, 25 Feb 2024 21:53:29 +0000 (22:53 +0100)
repl.js

diff --git a/repl.js b/repl.js
index 42aaa84be4cf04cd04be8ea390aa186cc7872f44..9f8ca4bfa98a872f60c027c795335973caa7ca18 100644 (file)
--- a/repl.js
+++ b/repl.js
@@ -1005,6 +1005,8 @@ import * as os from "os";
                     std.puts(a);
                 } else if (stack.indexOf(a) >= 0) {
                     std.puts("[circular]");
+                } else if (a instanceof Date) {
+                    std.puts("Date " + a.toGMTString().__quote());
                 } else if (has_jscalc && (a instanceof Fraction ||
                                         a instanceof Complex ||
                                         a instanceof Mod ||