Skip to content

Commit

Permalink
fix(time): enable dynamic time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
sabertazimi committed Apr 16, 2024
1 parent db86064 commit 80ebd04
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
10 changes: 2 additions & 8 deletions components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,9 @@ function Footer({
{' '}
<a href="https://github.com/sabertazimi/blog/actions">
<time
dateTime={new Date(buildTime).toLocaleString('zh-CN', {
hour12: false,
timeZone: 'Asia/Shanghai',
})}
dateTime={new Date(buildTime).toLocaleString('zh-CN', { hour12: false })}
>
{new Date(buildTime).toLocaleString('zh-CN', {
hour12: false,
timeZone: 'Asia/Shanghai',
})}
{new Date(buildTime).toLocaleString('zh-CN', { hour12: false })}
</time>
</a>
</span>
Expand Down
4 changes: 2 additions & 2 deletions components/Footer/__snapshots__/Footer.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ exports[`Footer should render correctly (snapshot) 1`] = `
href="https://github.com/sabertazimi/blog/actions"
>
<time
datetime="2022/1/1 16:00:00"
datetime="2022/1/1 08:00:00"
>
2022/1/1 16:00:00
2022/1/1 08:00:00
</time>
</a>
</span>
Expand Down
4 changes: 2 additions & 2 deletions layouts/__snapshots__/Layout.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,9 @@ exports[`Layout should render correctly (snapshot) 1`] = `
href="https://github.com/sabertazimi/blog/actions"
>
<time
datetime="2022/1/1 16:00:00"
datetime="2022/1/1 08:00:00"
>
2022/1/1 16:00:00
2022/1/1 08:00:00
</time>
</a>
</span>
Expand Down
4 changes: 2 additions & 2 deletions layouts/__snapshots__/PostLayout.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,9 @@ exports[`PostLayout should render correctly (snapshot) 1`] = `
href="https://github.com/sabertazimi/blog/actions"
>
<time
datetime="2022/1/1 16:00:00"
datetime="2022/1/1 08:00:00"
>
2022/1/1 16:00:00
2022/1/1 08:00:00
</time>
</a>
</span>
Expand Down
4 changes: 3 additions & 1 deletion mocks/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const time = Date.UTC(2022, 0, 1, 8, 0, 0)
const time = new Date(2022, 0, 1, 8, 0, 0).toLocaleString('zh-CN', {
hour12: false,
})

const baseProfile = {
username: 'sabertazimi',
Expand Down

0 comments on commit 80ebd04

Please sign in to comment.