Date Date : DateConstructor | { UTC ( year : number , monthIndex : number , date ?: number , hours ?: number , minutes ?: number , seconds ?: number , ms ?: number ) : number ; now ( ) : number ; parse ( s : string ) : number ; new ( ... args : any [] ) : { getVarDate : ( ( ) => VarDate ) ; [toPrimitive] ( hint : "default" ) : string ; [toPrimitive] ( hint : "string" ) : string ; [toPrimitive] ( hint : "number" ) : number ; [toPrimitive] ( hint : string ) : string | number ; getDate ( ) : number ; getDay ( ) : number ; getFullYear ( ) : number ; getHours ( ) : number ; getMilliseconds ( ) : number ; getMinutes ( ) : number ; getMonth ( ) : number ; getSeconds ( ) : number ; getTime ( ) : number ; getTimezoneOffset ( ) : number ; getUTCDate ( ) : number ; getUTCDay ( ) : number ; getUTCFullYear ( ) : number ; getUTCHours ( ) : number ; getUTCMilliseconds ( ) : number ; getUTCMinutes ( ) : number ; getUTCMonth ( ) : number ; getUTCSeconds ( ) : number ; setDate ( date : number ) : number ; setFullYear ( year : number , month ?: number , date ?: number ) : number ; setHours ( hours : number , min ?: number , sec ?: number , ms ?: number ) : number ; setMilliseconds ( ms : number ) : number ; setMinutes ( min : number , sec ?: number , ms ?: number ) : number ; setMonth ( month : number , date ?: number ) : number ; setSeconds ( sec : number , ms ?: number ) : number ; setTime ( time : number ) : number ; setUTCDate ( date : number ) : number ; setUTCFullYear ( year : number , month ?: number , date ?: number ) : number ; setUTCHours ( hours : number , min ?: number , sec ?: number , ms ?: number ) : number ; setUTCMilliseconds ( ms : number ) : number ; setUTCMinutes ( min : number , sec ?: number , ms ?: number ) : number ; setUTCMonth ( month : number , date ?: number ) : number ; setUTCSeconds ( sec : number , ms ?: number ) : number ; toDateString ( ) : string ; toISOString ( ) : string ; toJSON ( key ?: any ) : string ; toLocaleDateString ( ) : string ; toLocaleDateString ( locales ?: string | string [] , options ?: DateTimeFormatOptions ) : string ; toLocaleDateString ( locales ?: LocalesArgument , options ?: DateTimeFormatOptions ) : string ; toLocaleString ( ) : string ; toLocaleString ( locales ?: string | string [] , options ?: DateTimeFormatOptions ) : string ; toLocaleString ( locales ?: LocalesArgument , options ?: DateTimeFormatOptions ) : string ; toLocaleTimeString ( ) : string ; toLocaleTimeString ( locales ?: string | string [] , options ?: DateTimeFormatOptions ) : string ; toLocaleTimeString ( locales ?: LocalesArgument , options ?: DateTimeFormatOptions ) : string ; toString ( ) : string ; toTimeString ( ) : string ; toUTCString ( ) : string ; valueOf ( ) : number ; } ; }
Defined in node_modules/clock-mock/dist/mjs/index.d.ts:17
When entering a clock, the current state of the global is saved If another clock was already entered, it will revert back to that when exiting.
When we exit, if the monkey-patched global proxies get called, they will revert back to whatever the saved value was when they were patched. If that is another exited clock, it will proxy back to its original saved state, and so on, eventually hitting the original global state again if all clocks in the stack have been exited.