MCPcopy Index your code
hub / github.com/apitable/apitable / resizeFormat

Function resizeFormat

packages/components/src/components/calendar/utils.ts:45–73  ·  view source on GitHub ↗
(resizeData: IResizeFormat)

Source from the content-addressed store, hash-verified

43};
44
45export const resizeFormat = (resizeData: IResizeFormat) => {
46 let { startDate, endDate } = resizeData;
47 endDate = endDate || startDate;
48 startDate = startDate || endDate;
49 const { day, direction } = resizeData;
50 const isRight = direction === Direction.Right;
51 const isWarning = isAfter(startDate, endDate);
52 // update end date
53 if (isRight) {
54 // Correction date in case of alarm
55 endDate = add(isWarning ? startDate : endDate, { days: day });
56 // Right stretching is not allowed to be less than the start date
57 if (isAfter(startDate, endDate)) {
58 endDate = startDate;
59 }
60 } else { // update start date
61 const calcStartDate = subDays(startDate, day);
62 // Normal record left stretching is not allowed to be greater than the end date
63 if (!isWarning && isAfter(calcStartDate, endDate)) {
64 startDate = endDate;
65 } else if (
66 // The left stretch of abnormal records cannot be greater than the original start date
67 !(isWarning && isAfter(calcStartDate, startDate))
68 ) {
69 startDate = calcStartDate;
70 }
71 }
72 return { startDate, endDate };
73};
74
75/**
76 * Get the number of days in the current month

Callers 2

onMouseupFunction · 0.90
getLevelsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected