@hyperfrontend/immutable-api-utils/built-in-copy/datedate
Locked, prototype-pollution-resistant copy of the global Date constructor and its statics.
The Date constructor is wrapped in a createDate factory (with all overloads preserved) and Date.now, Date.parse, and Date.UTC are captured at module-load time and frozen into a tamper-proof namespace, so timestamp work keeps producing trustworthy values even if the global Date is later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain.
API Reference§
ƒ Functions
● Variables
(Safe copy) Namespace object containing Date factory and static methods. Note: Importing this imports all methods in this namespace (no tree-shaking).
(Safe copy) Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
Example
const timestamp = dateNow()
// => 1704067200000 (example timestamp)(Safe copy) Parses a string representation of a date.
Example
const timestamp = dateParse('2024-01-01T00:00:00Z')
// => 1704067200000(Safe copy) Returns the number of milliseconds in a Date object since January 1, 1970 UTC.
Example
const timestamp = dateUTC(2024, 0, 1, 12, 0, 0)
// => 1704110400000 (Jan 1, 2024 12:00:00 UTC)