-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime.js
More file actions
29 lines (27 loc) · 884 Bytes
/
Copy pathtime.js
File metadata and controls
29 lines (27 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
exports.local = function(year, month, day, hours, minutes, seconds, milliseconds) {
var date = new Date();
date.setFullYear(year, month, day);
date.setHours(hours || 0, minutes || 0, seconds || 0, milliseconds || 0);
return date;
};
exports.utc = function(year, month, day, hours, minutes, seconds, milliseconds) {
var date = new Date();
date.setUTCFullYear(year, month, day);
date.setUTCHours(hours || 0, minutes || 0, seconds || 0, milliseconds || 0);
return date;
};
exports.zone = function(tz, scope) {
return function() {
var o = process.env.TZ;
try {
process.env.TZ = tz;
new Date(0).toString(); // invalidate node's dst cache
new Date().toString();
scope.apply(this, arguments);
} finally {
process.env.TZ = o;
new Date(0).toString(); // invalidate node's dst cache
new Date().toString();
}
};
};