Skip to content

Commit

Permalink
fix: 时间时区+8
Browse files Browse the repository at this point in the history
  • Loading branch information
xjq7 committed Oct 30, 2022
1 parent cb9d39d commit 99e6839
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions server/src/controller/stat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export class StatController {
@Get('/')
async getStat() {
try {
const startTime = dayjs(
dayjs().format('YYYY-MM-DD') + ' 00:00:00'
).toISOString();
const endTime = dayjs(
dayjs().format('YYYY-MM-DD') + ' 23:59:59'
).toISOString();
const startTime = dayjs(dayjs().format('YYYY-MM-DD') + ' 00:00:00')
.add(8, 'h')
.toISOString();
const endTime = dayjs(dayjs().format('YYYY-MM-DD') + ' 23:59:59')
.add(8, 'h')
.toISOString();

const result = await prisma.stat.findMany({
where: { createdAt: { lte: endTime, gte: startTime } },
Expand Down Expand Up @@ -46,7 +46,7 @@ export class StatController {
code: 0,
};
}

const now = dayjs().add(8, 'h').toISOString();
try {
const ipCache = await redisStore.get(IP_PREFIX + ip);

Expand All @@ -70,6 +70,7 @@ export class StatController {
city,
province,
isp,
createdAt: now,
},
});
} catch (error) {
Expand Down

0 comments on commit 99e6839

Please sign in to comment.