File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -11,20 +11,28 @@ const {
11
11
const { setUnrefTimeout } = require ( 'internal/timers' ) ;
12
12
const { PerformanceEntry, notify } = internalBinding ( 'performance' ) ;
13
13
14
+ let nowCache ;
14
15
let utcCache ;
15
16
17
+ function nowDate ( ) {
18
+ if ( ! nowCache ) cache ( ) ;
19
+ return nowCache ;
20
+ }
21
+
16
22
function utcDate ( ) {
17
23
if ( ! utcCache ) cache ( ) ;
18
24
return utcCache ;
19
25
}
20
26
21
27
function cache ( ) {
22
28
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 ) ) ;
25
32
}
26
33
27
34
function resetCache ( ) {
35
+ nowCache = undefined ;
28
36
utcCache = undefined ;
29
37
}
30
38
@@ -47,6 +55,7 @@ function emitStatistics(statistics) {
47
55
module . exports = {
48
56
kOutHeaders : Symbol ( 'kOutHeaders' ) ,
49
57
kNeedDrain : Symbol ( 'kNeedDrain' ) ,
58
+ nowDate,
50
59
utcDate,
51
60
emitStatistics
52
61
} ;
You can’t perform that action at this time.
0 commit comments