Skip to content

Commit d7ac095

Browse files
committed
treat initial date scheduled as datetime
1 parent d383c25 commit d7ac095

5 files changed

Lines changed: 10 additions & 14 deletions

File tree

src/backend/src/utils/google-integration.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ export const createCalendarEvent = async (
233233
location: isInPerson ? location : zoomLink,
234234
summary: eventTitle,
235235
start: slot.allDay
236-
? { date: slot.startTime ? toDateString(slot.startTime) : undefined }
236+
? { date: slot.startTime ? slot.startTime.toISOString().split('T')[0] : undefined }
237237
: {
238238
dateTime: slot.startTime ? slot.startTime.toISOString() : undefined,
239239
timeZone: 'America/New_York'
240240
},
241241
end: slot.allDay
242-
? { date: slot.endTime ? toDateString(slot.endTime) : undefined }
242+
? { date: slot.endTime ? slot.endTime.toISOString().split('T')[0] : undefined }
243243
: {
244244
dateTime: slot.endTime ? slot.endTime.toISOString() : undefined,
245245
timeZone: 'America/New_York'

src/frontend/src/pages/CalendarPage/AvailabilityScheduleView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from '@mui/material';
2-
import { Availability, dbDateToLocalDate, Event, EventWithMembers, getDayOfWeek, getNextSevenDays, User } from 'shared';
2+
import { Availability, Event, EventWithMembers, getDayOfWeek, getNextSevenDays, User } from 'shared';
33
import React, { useState } from 'react';
44
import { enumToArray, getBackgroundColor, NUMBER_OF_TIME_SLOTS, REVIEW_TIMES } from '../../utils/design-review.utils';
55
import { datePipe } from '../../utils/pipes';

src/frontend/src/pages/CalendarPage/Components/EventAvailabilityPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { useQuery as useQueryParam } from '../../../hooks/utils.hooks';
88
import { Box, Grid, Typography, useTheme } from '@mui/material';
99
import {
1010
Availability,
11-
dbDateToLocalDate,
1211
getMostRecentAvailabilities,
1312
User,
1413
UserWithScheduleSettings,

src/frontend/src/pages/HomePage/components/EventCard.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
77
import { LocationOnOutlined, Computer } from '@mui/icons-material';
88
import { useHistory } from 'react-router-dom';
99
import { NERButton } from '../../../components/NERButton';
10-
import { formatDateOnly, formatEventDate } from 'shared';
10+
import { formatDateOnly } from 'shared';
1111

1212
interface EventProps {
1313
event: Event;
@@ -58,10 +58,7 @@ const DisplayStatus: React.FC<EventProps> = ({ event, user }) => {
5858
);
5959
};
6060

61-
const getWeekday = (date: Date, utc = false): string => {
62-
if (utc) {
63-
return formatDateOnly(date, 'dddd');
64-
}
61+
const getWeekday = (date: Date): string => {
6562
const weekdays: string[] = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
6663
return weekdays[date.getDay()];
6764
};
@@ -70,9 +67,7 @@ const UpcomingEventCard: React.FC<EventProps> = ({ event, user }) => {
7067
const theme = useTheme();
7168
const firstScheduledDate = event.initialDateScheduled || event.scheduledTimes[0]?.startTime;
7269
const displayDate = firstScheduledDate ? new Date(firstScheduledDate) : new Date();
73-
// initialDateScheduled is a date-only field (@db.Date), scheduledTimes startTime is a full datetime
74-
const isDateOnly = !!event.initialDateScheduled;
75-
const formattedDate = isDateOnly ? formatDateOnly(displayDate, 'MM/DD') : formatEventDate(displayDate);
70+
const formattedDate = formatDateOnly(displayDate);
7671

7772
const [firstWorkPackage] = event.workPackages;
7873

@@ -110,7 +105,7 @@ const UpcomingEventCard: React.FC<EventProps> = ({ event, user }) => {
110105
<Stack direction="row" spacing={1} sx={{ mt: 0.5 }}>
111106
<Typography>{<CalendarMonthIcon sx={{ fontSize: 21 }} />}</Typography>
112107
<Typography fontWeight={'regular'} variant="body2">
113-
{getWeekday(displayDate, isDateOnly) +
108+
{getWeekday(displayDate) +
114109
', ' +
115110
formattedDate +
116111
' @ ' +

src/shared/src/date-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const addWeeksToDate = (start: Date, weeks: number) => addDaysToDate(start, week
2020
* @returns the outcome of adding the days to the start date
2121
*/
2222
const addDaysToDate = (start: Date, days: number) => {
23-
return new Date(start.getTime() + days * 24 * 60 * 60 * 1000);
23+
const end = new Date(start);
24+
end.setDate(start.getDate() + days);
25+
return end;
2426
};
2527

2628
/**

0 commit comments

Comments
 (0)