File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -11,20 +11,28 @@ const {
1111const { setUnrefTimeout } = require ( 'internal/timers' ) ;
1212const { PerformanceEntry, notify } = internalBinding ( 'performance' ) ;
1313
14+ let nowCache ;
1415let utcCache ;
1516
17+ function nowDate ( ) {
18+ if ( ! nowCache ) cache ( ) ;
19+ return nowCache ;
20+ }
21+
1622function utcDate ( ) {
1723 if ( ! utcCache ) cache ( ) ;
1824 return utcCache ;
1925}
2026
2127function cache ( ) {
2228 const d = new Date ( ) ;
23- utcCache = d . toUTCString ( ) ;
24- setUnrefTimeout ( resetCache , 1000 - d . getMilliseconds ( ) ) ;
29+ nowCache = DatePrototypeValueOf ( d ) ;
30+ utcCache = DatePrototypeToUTCString ( d ) ;
31+ setUnrefTimeout ( resetCache , 1000 - DatePrototypeGetMilliseconds ( d ) ) ;
2532}
2633
2734function resetCache ( ) {
35+ nowCache = undefined ;
2836 utcCache = undefined ;
2937}
3038
@@ -47,6 +55,7 @@ function emitStatistics(statistics) {
4755module . exports = {
4856 kOutHeaders : Symbol ( 'kOutHeaders' ) ,
4957 kNeedDrain : Symbol ( 'kNeedDrain' ) ,
58+ nowDate,
5059 utcDate,
5160 emitStatistics
5261} ;
You can’t perform that action at this time.
0 commit comments