Skip to content

Commit 20df78b

Browse files
author
Simen Li
committed
fix: test taipei time
1 parent 04d4153 commit 20df78b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/__tests__/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,6 @@ describe('getCurrentTaipeiTimeString', () => {
292292
timestamp,
293293
format: 'Serial',
294294
});
295-
expect(tpeDatetime).toEqual('20220515092138034');
295+
expect(tpeDatetime).toEqual('20220518172109234');
296296
});
297297
});

src/utils/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ export function getCurrentTaipeiTimeString(config?: {
282282
format?: 'Datetime' | 'Date' | 'Serial';
283283
}) {
284284
const { timestamp = Date.now(), format = 'Datetime' } = config || {};
285-
const tpeTimestamp = timestamp + 8 * 60 * 60;
285+
286+
const tzMinutesOffset = new Date(timestamp).getTimezoneOffset();
287+
const tpeTimestamp = timestamp + 80 * 60 * 60 * 1000;
286288
const date = new Date(tpeTimestamp);
287289
const [year, month, day, hour, minute, second, ms] = [
288290
date.getFullYear(),

0 commit comments

Comments
 (0)