Skip to content

Commit

Permalink
fix: utc time error
Browse files Browse the repository at this point in the history
  • Loading branch information
lybenson committed Jul 5, 2024
1 parent a825452 commit ab6a6c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/renderer/src/lib/dayjs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
dayjs.locale('zh-cn')
import utc from 'dayjs/plugin/utc'

dayjs.extend(utc)

export default dayjs
24 changes: 15 additions & 9 deletions src/renderer/src/pages/sentence/sentence-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ export default function SentenceList({
group?: SentenceGroupsReturn
}) {
const now = dayjs()
console.log(now.format('YYYY-MM-DD HH:mm:ss'))

const tabs = [
{
label: '今日新增',
value: 'today',
dateRange: {
start: now.startOf('day').format('YYYY-MM-DD HH:mm:ss'),
end: now.endOf('day').format('YYYY-MM-DD HH:mm:ss')
start: now.startOf('day').utc().format('YYYY-MM-DD HH:mm:ss'),
end: now.endOf('day').utc().format('YYYY-MM-DD HH:mm:ss')
}
},
{
Expand All @@ -35,32 +36,37 @@ export default function SentenceList({
start: now
.subtract(1, 'day')
.startOf('day')
.utc()
.format('YYYY-MM-DD HH:mm:ss'),
end: now.subtract(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss')
end: now
.subtract(1, 'day')
.endOf('day')
.utc()
.format('YYYY-MM-DD HH:mm:ss')
}
},
{
label: '最近三日',
value: 'last3days',
dateRange: {
start: now.subtract(3, 'day').format('YYYY-MM-DD HH:mm:ss'),
end: now.format('YYYY-MM-DD HH:mm:ss')
start: now.subtract(3, 'day').utc().format('YYYY-MM-DD HH:mm:ss'),
end: now.utc().format('YYYY-MM-DD HH:mm:ss')
}
},
{
label: '最近一周',
value: 'last7days',
dateRange: {
start: now.subtract(1, 'week').format('YYYY-MM-DD HH:mm:ss'),
end: now.format('YYYY-MM-DD HH:mm:ss')
start: now.subtract(1, 'week').utc().format('YYYY-MM-DD HH:mm:ss'),
end: now.utc().format('YYYY-MM-DD HH:mm:ss')
}
},
{
label: '最近一月',
value: 'last30days',
dateRange: {
start: now.subtract(1, 'month').format('YYYY-MM-DD HH:mm:ss'),
end: now.format('YYYY-MM-DD HH:mm:ss')
start: now.subtract(1, 'month').utc().format('YYYY-MM-DD HH:mm:ss'),
end: now.utc().format('YYYY-MM-DD HH:mm:ss')
}
},
{
Expand Down

0 comments on commit ab6a6c1

Please sign in to comment.