2017-03-05 21:13:09 -05:00
|
|
|
'use strict';
|
|
|
|
|
2019-11-30 16:55:29 +01:00
|
|
|
const {
|
|
|
|
Symbol,
|
2020-09-30 02:29:40 +08:00
|
|
|
Date,
|
2020-11-17 12:54:37 +01:00
|
|
|
DatePrototypeGetMilliseconds,
|
|
|
|
DatePrototypeToUTCString,
|
2019-11-30 16:55:29 +01:00
|
|
|
} = primordials;
|
|
|
|
|
2017-12-20 21:50:19 -05:00
|
|
|
const { setUnrefTimeout } = require('internal/timers');
|
2021-01-28 16:34:27 -08:00
|
|
|
|
2019-11-12 15:46:28 +00:00
|
|
|
let utcCache;
|
2018-08-23 16:46:07 +02:00
|
|
|
|
2016-10-17 11:38:52 -07:00
|
|
|
function utcDate() {
|
2018-08-23 16:46:07 +02:00
|
|
|
if (!utcCache) cache();
|
|
|
|
return utcCache;
|
|
|
|
}
|
2017-12-20 21:50:19 -05:00
|
|
|
|
2018-08-23 16:46:07 +02:00
|
|
|
function cache() {
|
|
|
|
const d = new Date();
|
2020-11-17 12:54:37 +01:00
|
|
|
utcCache = DatePrototypeToUTCString(d);
|
|
|
|
setUnrefTimeout(resetCache, 1000 - DatePrototypeGetMilliseconds(d));
|
2016-10-17 11:38:52 -07:00
|
|
|
}
|
2017-12-20 21:50:19 -05:00
|
|
|
|
|
|
|
function resetCache() {
|
2018-08-23 16:46:07 +02:00
|
|
|
utcCache = undefined;
|
2017-12-20 21:50:19 -05:00
|
|
|
}
|
2016-10-17 11:38:52 -07:00
|
|
|
|
2017-03-05 21:13:09 -05:00
|
|
|
module.exports = {
|
2019-08-12 08:52:18 +02:00
|
|
|
kOutHeaders: Symbol('kOutHeaders'),
|
2021-03-29 11:20:57 +02:00
|
|
|
kNeedDrain: Symbol('kNeedDrain'),
|
2019-06-30 22:37:18 +02:00
|
|
|
utcDate,
|
2017-03-05 21:13:09 -05:00
|
|
|
};
|