fix colection create api (#766)

Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
Archer
2024-01-23 09:01:24 +08:00
committed by GitHub
parent aab6ee51eb
commit 379673cae1
143 changed files with 40737 additions and 274 deletions

View File

@@ -1,10 +1,18 @@
// The number of days left in the month is calculated as 30 days per month, and less than 1 day is calculated as 1 day
export const getMonthRemainingDays = () => {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth();
const date = now.getDate();
const days = new Date(year, month + 1, 0).getDate();
const remainingDays = days - date;
return remainingDays + 1;
export const getMonthRemainingDays = (startDate = new Date()) => {
const year = startDate.getFullYear();
const month = startDate.getMonth();
const endDay = new Date(year, month + 1, 0, 0, 0, 0);
return calculateDaysBetweenDates(startDate, endDay);
};
export const calculateDaysBetweenDates = (date1: Date, date2: Date) => {
const oneDay = 24 * 60 * 60 * 1000;
const firstDate = new Date(date1).getTime();
const secondDate = new Date(date2).getTime();
const differenceInTime = Math.abs(secondDate - firstDate);
const differenceInDays = Math.floor(differenceInTime / oneDay);
return differenceInDays;
};