Skip to content

Commit 7aab98a

Browse files
committed
修正时间
1 parent b7c66d7 commit 7aab98a

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/background.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ function initOutputData() {
1111
public: true,
1212
generator: 'httpmonitor@lianzhi.com',
1313
version: '1.0',
14-
date: '',
14+
date: generateDate(),
1515
requests: []
1616
}
1717
}
1818

19+
function generateDate()
20+
{
21+
var x = new Date();
22+
var y = x.getFullYear();
23+
var m = x.getMonth()+1; m = m < 10 ? '0' + m : m;
24+
var d = x.getDate(); d = d < 10 ? '0' + d : d;
25+
var h = x.getHours(); h = h < 10 ? '0' + h : h;
26+
var i = x.getMinutes(); i = i < 10 ? '0' + i : i;
27+
var s = x.getSeconds(); s = s < 10 ? '0' + s : s;
28+
return [y, m, d, 'T', h, i, s].join('')
29+
}
30+
1931
function resetSession() {
2032
requestSent = {};
2133
outputData = initOutputData();
@@ -93,12 +105,12 @@ function serializeRequest(callType, request, response) {
93105

94106
function exportSession() {
95107
if (outputData.requests.length < 1) return;
96-
outputData.date = new Date().toISOString()
108+
outputData.date = generateDate();
97109

98110
var blob = new Blob([JSON.stringify(outputData, null, 2)], {
99111
type: "text/plain;charset=utf-8"
100112
});
101113

102-
var fileNameSuffix = outputData.date.replace(/:/g, "-");
114+
var fileNameSuffix = outputData.date;
103115
saveAs(blob, "HttpMonitor" + fileNameSuffix + ".txt");
104116
}

0 commit comments

Comments
 (0)