use toJSON for Date in value explorer

This commit is contained in:
Dmitry Vasilev
2024-02-28 01:48:37 +08:00
parent e70eaa31d5
commit 2cf94fe651
2 changed files with 5 additions and 17 deletions

View File

@@ -242,9 +242,9 @@ const make_patched_method = (window, original, name, use_context) => {
}
const patch_Date = (window) => {
const Date = window.Date
const Date_patched = make_patched_method(window, Date, 'Date', false)
window.Date = function(...args) {
const Date_original = window.Date
const Date_patched = make_patched_method(window, Date_original, 'Date', false)
window.Date = function Date(...args) {
if(args.length == 0) {
// return current Date, IO operation
if(new.target != null) {
@@ -255,14 +255,12 @@ const patch_Date = (window) => {
} else {
// pure function
if(new.target != null) {
return new Date(...args)
return new Date_original(...args)
} else {
return Date(...args)
return Date_original(...args)
}
}
}
window.Date.__original = Date
window.Date.parse = Date.parse
window.Date.now = Date.now
window.Date.UTC = Date.UTC