mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
25 lines
659 B
TypeScript
25 lines
659 B
TypeScript
|
import { describe, expect, it } from "vitest"
|
||
|
import { tranformToUTC } from "#/utils/date"
|
||
|
|
||
|
describe("transform Beijing time to UTC in different timezone", () => {
|
||
|
const a = "2024/10/3 12:26:16"
|
||
|
const b = 1727929576000
|
||
|
it("in UTC", () => {
|
||
|
Object.assign(process.env, { TZ: "UTC" })
|
||
|
const date = tranformToUTC(a)
|
||
|
expect(date).toBe(b)
|
||
|
})
|
||
|
|
||
|
it("in Beijing", () => {
|
||
|
Object.assign(process.env, { TZ: "Asia/Shanghai" })
|
||
|
const date = tranformToUTC(a)
|
||
|
expect(date).toBe(b)
|
||
|
})
|
||
|
|
||
|
it("in New York", () => {
|
||
|
Object.assign(process.env, { TZ: "America/New_York" })
|
||
|
const date = tranformToUTC(a)
|
||
|
expect(date).toBe(b)
|
||
|
})
|
||
|
})
|