The global `Date` object in mongosh is not the language built-in `Date`, unlike in the legacy shell. This breaks `Date.now()` usage.
A simple way to solve this would be to make the `Date` BSON function inherit from the native `Date` function like ES6 classes do, i.e.
Object.setPrototypeOf(BSONDate, JSDate); Object.setPrototypeOf(BSONDate.prototype, JSDate.prototype);
However, as far as I can tell, the only difference between our shell-bson Date function and the builtin one is that, when multiple arguments are passed, our shell-bson Date function assumes UTC instead of the local timezone.
This is mismatched with both Node.js and the legacy shell, and I’m wondering if it makes sense to just remove our custom Date function entirely.