Skip to content

Commit c43df87

Browse files
committed
fix: use utc timezone
1 parent d06e927 commit c43df87

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/logger/__tests__/transports/console.test.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('console', () => {
2525

2626
strictEqual(process.stdout.write.mock.callCount(), 4);
2727
deepStrictEqual(callsArgs, [
28-
'[21:00:00.000]',
28+
'[00:00:00.000]',
2929
' \x1B[34mDEBUG\x1B[39m',
3030
': Test message',
3131
'\n',
@@ -51,7 +51,7 @@ describe('console', () => {
5151

5252
strictEqual(process.stdout.write.mock.callCount(), 4);
5353
deepStrictEqual(callsArgs, [
54-
'[21:00:00.000]',
54+
'[00:00:00.000]',
5555
' \x1B[32mINFO\x1B[39m',
5656
': Test message',
5757
'\n',
@@ -78,7 +78,7 @@ describe('console', () => {
7878

7979
strictEqual(process.stdout.write.mock.callCount(), 4);
8080
deepStrictEqual(callsArgs, [
81-
'[21:00:00.000]',
81+
'[00:00:00.000]',
8282
' \x1B[35mERROR\x1B[39m',
8383
': Test message',
8484
'\n',
@@ -105,7 +105,7 @@ describe('console', () => {
105105

106106
strictEqual(process.stdout.write.mock.callCount(), 4);
107107
deepStrictEqual(callsArgs, [
108-
'[21:00:00.000]',
108+
'[00:00:00.000]',
109109
' \x1B[31mFATAL\x1B[39m',
110110
': Test message',
111111
'\n',
@@ -141,7 +141,7 @@ describe('console', () => {
141141

142142
strictEqual(process.stdout.write.mock.callCount(), 6);
143143
deepStrictEqual(callsArgs, [
144-
'[21:00:00.000]',
144+
'[00:00:00.000]',
145145
' \x1B[32mINFO\x1B[39m',
146146
': Test message',
147147
' at test.md',
@@ -171,7 +171,7 @@ describe('console', () => {
171171

172172
strictEqual(process.stdout.write.mock.callCount(), 5);
173173
deepStrictEqual(callsArgs, [
174-
'[21:00:00.000]',
174+
'[00:00:00.000]',
175175
' \x1B[32mINFO\x1B[39m',
176176
' (child1)',
177177
': Test message',
@@ -201,7 +201,7 @@ describe('console', () => {
201201

202202
strictEqual(process.stdout.write.mock.callCount(), 4);
203203
deepStrictEqual(callsArgs, [
204-
'[21:00:00.000]',
204+
'[00:00:00.000]',
205205
' INFO',
206206
': Test message',
207207
'\n',

src/logger/__tests__/transports/github.test.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('github', () => {
2525

2626
strictEqual(process.stdout.write.mock.callCount(), 1);
2727
deepStrictEqual(callsArgs, [
28-
'::debug::[21:00:00.000] \x1B[34mDEBUG\x1B[39m: Test message\n',
28+
'::debug::[00:00:00.000] \x1B[34mDEBUG\x1B[39m: Test message\n',
2929
]);
3030
});
3131

@@ -48,7 +48,7 @@ describe('github', () => {
4848

4949
strictEqual(process.stdout.write.mock.callCount(), 1);
5050
deepStrictEqual(callsArgs, [
51-
'::notice ::[21:00:00.000] \x1B[32mINFO\x1B[39m: Test message\n',
51+
'::notice ::[00:00:00.000] \x1B[32mINFO\x1B[39m: Test message\n',
5252
]);
5353
});
5454

@@ -72,7 +72,7 @@ describe('github', () => {
7272

7373
strictEqual(process.stdout.write.mock.callCount(), 1);
7474
deepStrictEqual(callsArgs, [
75-
'::error ::[21:00:00.000] \x1B[35mERROR\x1B[39m: Test message\n',
75+
'::error ::[00:00:00.000] \x1B[35mERROR\x1B[39m: Test message\n',
7676
]);
7777
});
7878

@@ -96,7 +96,7 @@ describe('github', () => {
9696

9797
strictEqual(process.stdout.write.mock.callCount(), 1);
9898
deepStrictEqual(callsArgs, [
99-
'::error ::[21:00:00.000] \x1B[31mFATAL\x1B[39m: Test message\n',
99+
'::error ::[00:00:00.000] \x1B[31mFATAL\x1B[39m: Test message\n',
100100
]);
101101
});
102102

@@ -129,7 +129,7 @@ describe('github', () => {
129129

130130
strictEqual(process.stdout.write.mock.callCount(), 1);
131131
deepStrictEqual(callsArgs, [
132-
'::notice file=test.md,line=1,endLine=1::[21:00:00.000] \x1B[32mINFO\x1B[39m: Test message\n',
132+
'::notice file=test.md,line=1,endLine=1::[00:00:00.000] \x1B[32mINFO\x1B[39m: Test message\n',
133133
]);
134134
});
135135

@@ -153,7 +153,7 @@ describe('github', () => {
153153

154154
strictEqual(process.stdout.write.mock.callCount(), 1);
155155
deepStrictEqual(callsArgs, [
156-
'::notice ::[21:00:00.000] \x1B[32mINFO\x1B[39m (child1): Test message\n',
156+
'::notice ::[00:00:00.000] \x1B[32mINFO\x1B[39m (child1): Test message\n',
157157
]);
158158
});
159159

@@ -179,7 +179,7 @@ describe('github', () => {
179179

180180
strictEqual(process.stdout.write.mock.callCount(), 1);
181181
deepStrictEqual(callsArgs, [
182-
'::notice ::[21:00:00.000] INFO: Test message\n',
182+
'::notice ::[00:00:00.000] INFO: Test message\n',
183183
]);
184184
});
185185
});

src/logger/utils/time.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
'use strict';
22

33
/**
4-
* Formats a Unix timestamp in milliseconds as a human-readable time string for
5-
* CLI output.
4+
* Formats a Unix timestamp in milliseconds as a human-readable time string
5+
* in UTC timezone for CLI output.
66
*
77
* @param {number} timestamp
88
* @returns {string}
99
*/
1010
export const prettifyTimestamp = timestamp => {
1111
const date = new Date(timestamp);
1212

13-
const hours = date.getHours().toString().padStart(2, '0');
14-
const minutes = date.getMinutes().toString().padStart(2, '0');
15-
const seconds = date.getSeconds().toString().padStart(2, '0');
16-
const milliseconds = date.getMilliseconds().toString().padStart(3, '0');
13+
const hours = date.getUTCHours().toString().padStart(2, '0');
14+
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
15+
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
16+
const milliseconds = date.getUTCMilliseconds().toString().padStart(3, '0');
1717

1818
return `${hours}:${minutes}:${seconds}.${milliseconds}`;
1919
};

0 commit comments

Comments
 (0)