위의 케이스를 고려하여 완성된 로직은 다음과 같다.
const checkIsFirstChatToday = (
targetIndex: number,
chatLogData: Array<[string, ChatLog]>
): boolean => {
if (targetIndex === 0) {
return true;
}
const prevTime = chatLogData[targetIndex - 1][1].time;
const targetTime = chatLogData[targetIndex][1].time;
return !checkDateIsSameDate(new Date(prevTime), new Date(targetTime));
};