Bug: Date() is returning the wrong value (UTC, versus local time) in version 4
In version 4, new Date() is returning a UTC datetime instead of the required local time.
If you run the following code in any browser -- or in Aren version 3.95p:
currDt = new Date ();
lclStr = currDt.toLocaleString (); // This gets confused in Aren if date math is done?!
console.log ("currDt: " + currDt);
console.log ("lclStr: " + lclStr);
You will get the local machine's date and time, including any offset due to "daylight savings time".
EG:
currDt: Thu Oct 02 2025 20:58:52 GMT-0700 (Pacific Daylight Time)
lclStr: 10/2/2025, 8:58:52 PM
or
currDt: 2025-10-02 20:55:08.164-07:00
lclStr: 2025-10-02 20:55:08.164-07:00
This is because the JavaScript (ECMAScript) spec requires toLocaleString() to display local values and the de-facto standard for new Date() is that it returns (stringifies to) local time. (Although this last requires careful reading of several sections of the standard.)
But in Aren 4, you get:
currDt: Fri Oct 03 2025 04:08:50 GMT+0000
lclStr: 10/03/2025, 04:08:50 AM
This is a double error as toLocaleString () is also failing to ascertain the local time
This screws up all manor of attempts to accurately datetime stamp local files and leaves no programmatic way to even know what the local time is.
Finally, a related but less critical bug: .toLocaleDateString() returns both the wrong date and the wrong format.
That is, this code:
dateDisplayOptions = { month: "2-digit", day: "2-digit" };
displayDate = (new Date () ).toLocaleDateString("en-US", dateDisplayOptions);
console.log ("displayDate: " + displayDate);
Displays:
displayDate: 10/03/2025
When it should display:
displayDate: 10/02
At the moment on my machine as I'm currently a calendar date behind Old Blighty. ;)
If you run the following code in any browser -- or in Aren version 3.95p:
currDt = new Date ();
lclStr = currDt.toLocaleString (); // This gets confused in Aren if date math is done?!
console.log ("currDt: " + currDt);
console.log ("lclStr: " + lclStr);
You will get the local machine's date and time, including any offset due to "daylight savings time".
EG:
currDt: Thu Oct 02 2025 20:58:52 GMT-0700 (Pacific Daylight Time)
lclStr: 10/2/2025, 8:58:52 PM
or
currDt: 2025-10-02 20:55:08.164-07:00
lclStr: 2025-10-02 20:55:08.164-07:00
This is because the JavaScript (ECMAScript) spec requires toLocaleString() to display local values and the de-facto standard for new Date() is that it returns (stringifies to) local time. (Although this last requires careful reading of several sections of the standard.)
But in Aren 4, you get:
currDt: Fri Oct 03 2025 04:08:50 GMT+0000
lclStr: 10/03/2025, 04:08:50 AM
This is a double error as toLocaleString () is also failing to ascertain the local time
This screws up all manor of attempts to accurately datetime stamp local files and leaves no programmatic way to even know what the local time is.
Finally, a related but less critical bug: .toLocaleDateString() returns both the wrong date and the wrong format.
That is, this code:
dateDisplayOptions = { month: "2-digit", day: "2-digit" };
displayDate = (new Date () ).toLocaleDateString("en-US", dateDisplayOptions);
console.log ("displayDate: " + displayDate);
Displays:
displayDate: 10/03/2025
When it should display:
displayDate: 10/02
At the moment on my machine as I'm currently a calendar date behind Old Blighty. ;)