Skip to content

Commit

Permalink
Merge pull request #116 from Together42/develop
Browse files Browse the repository at this point in the history
Update 토요근무 가능토록 수정
  • Loading branch information
jhj9109 committed Sep 28, 2023
2 parents 6a6320b + 6993c8f commit 3bcf7f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/Rotation/Rotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getDaysInMonth,
getFirstDayOfMonth,
isWeekend,
isSunday,
MONTH_IN_YEAR,
getFourthWeekFromMondayToFridayPeriod,
getNextAttendPeriodStrFunction,
Expand Down Expand Up @@ -95,6 +96,7 @@ const setTileDisabled =

const rules = {
weekdayOnly: ({ date, view: _view }) => isWeekend(date),
exceptSunday: ({ date, view: _view }) => !isSunday(date),
} as const satisfies Record<string, TileRule>;

/**
Expand Down Expand Up @@ -244,7 +246,7 @@ const SelectDateBox = ({
activeStartDate={getActiveStartDate(currentDate)}
minDate={setLimitMinDate(currentDate)}
maxDate={setLimitMaxDate(currentDate)}
tileDisabled={setTileDisabled([rules.weekdayOnly])}
tileDisabled={setTileDisabled([rules.exceptSunday])}
tileClassName={setTileClassName}
onClickDay={onClickDay}
></Calendar>
Expand Down
3 changes: 3 additions & 0 deletions src/components/Rotation/rotation_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const MONTH_IN_YEAR = 12;
export const DAY_IN_WEEK = 7;

export const DAY_OF_THURSDAY = 4;
export const DAY_OF_SUNDAY = 0;

export const getKoreaDate = (date = new Date()) => {
const utc = date.getTime() + date.getTimezoneOffset() * MILLISEC_IN_MIN;
Expand All @@ -23,6 +24,8 @@ export const getKoreaDate = (date = new Date()) => {
};
export const isWeekend = (day: Date | number) =>
typeof day === 'number' ? (day % DAY_IN_WEEK) % 6 === 0 : day.getDay() % 6 === 0;
export const isSunday = (day: Date | number) =>
typeof day === 'number' ? (day % DAY_IN_WEEK) === DAY_OF_SUNDAY : day.getDay() === DAY_OF_SUNDAY;

/**
* get...DateOfMonth: 특정달의 첫날 || 마지막날 리턴
Expand Down

0 comments on commit 3bcf7f7

Please sign in to comment.