mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-16 22:13:47 +08:00
123
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { addHours } from "date-fns";
|
||||
|
||||
export function getCurrentTime(now?: Date): string {
|
||||
if (!now) {
|
||||
const now = new Date();
|
||||
@@ -16,3 +18,19 @@ export function getCurrentTime(now?: Date): string {
|
||||
|
||||
return formatter.format(now);
|
||||
}
|
||||
|
||||
export function getCurStartEnd(now = new Date()) {
|
||||
const startOfTheDayInTimeZone = new Date(
|
||||
now.getFullYear(),
|
||||
now.getMonth(),
|
||||
now.getDate(),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
const endOfTheDayInTimeZone = addHours(startOfTheDayInTimeZone, +24); // 当天的结束时间
|
||||
return {
|
||||
startOfTheDayInTimeZone,
|
||||
endOfTheDayInTimeZone,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user