@@ -3,11 +3,13 @@ import {
33 TaskWithAssignees ,
44 endOfDayTomorrow ,
55 startOfDayTomorrow ,
6+ startOfTodayEST ,
7+ startOfTomorrowEST ,
68 usersToSlackPings ,
79 EventWithAttendees
810} from '../utils/notifications.utils.js' ;
911import { sendMessage } from '../integrations/slack.js' ;
10- import { daysBetween , startOfDay , wbsPipe , formatTimeForSlack } from 'shared' ;
12+ import { daysBetween , wbsPipe , formatTimeForSlack } from 'shared' ;
1113import { buildDueString , sendThreadResponse } from '../utils/slack.utils.js' ;
1214import WorkPackagesService from './work-packages.services.js' ;
1315import { addWeeksToDate } from 'shared' ;
@@ -30,7 +32,7 @@ export default class NotificationsService {
3032 static async sendTaskDeadlineSlackNotifications ( ) {
3133 const endOfDay = endOfDayTomorrow ( ) ;
3234
33- if ( endOfDay . getDay ( ) === 0 || endOfDay . getDay ( ) === 2 || endOfDay . getDay ( ) === 4 ) return ;
35+ if ( endOfDay . getUTCDay ( ) === 0 || endOfDay . getUTCDay ( ) === 2 || endOfDay . getUTCDay ( ) === 4 ) return ;
3436
3537 const tasks = await prisma . task . findMany ( {
3638 where : {
@@ -81,7 +83,8 @@ export default class NotificationsService {
8183 const messageBlock = tasks
8284 . map ( ( task ) => {
8385 // prisma call earlier allows the forced unwrap (deadline is guaranteed to be a non-null value)
84- const daysUntilDeadline = daysBetween ( task . deadline ! , new Date ( ) ) ;
86+ const todayMidnightUTC = new Date ( new Date ( ) . setUTCHours ( 0 , 0 , 0 , 0 ) ) ;
87+ const daysUntilDeadline = daysBetween ( task . deadline ! , todayMidnightUTC ) ;
8588
8689 return `${ usersToSlackPings ( task . assignees ?? [ ] ) } <https://finishlinebyner.com/projects/${ wbsPipe (
8790 task . wbsElement
@@ -121,8 +124,8 @@ export default class NotificationsService {
121124 * Sends Slack notifications for all events scheduled for today whose event type has sendSlackNotifications enabled
122125 */
123126 static async sendEventSlackNotifications ( ) {
124- const endOfToday = startOfDayTomorrow ( ) ;
125- const startOfToday = startOfDay ( new Date ( ) ) ;
127+ const endOfToday = startOfTomorrowEST ( ) ;
128+ const startOfToday = startOfTodayEST ( ) ;
126129
127130 const events = await prisma . event . findMany ( {
128131 where : {
@@ -231,7 +234,7 @@ export default class NotificationsService {
231234 * Sends the sponsor task slack notifications for all tasks with a notify date of today
232235 */
233236 static async sendSponsorTaskNotifications ( ) {
234- const startOfToday = startOfDay ( new Date ( ) ) ;
237+ const startOfToday = new Date ( new Date ( ) . setUTCHours ( 0 , 0 , 0 , 0 ) ) ;
235238 const endOfToday = startOfDayTomorrow ( ) ;
236239
237240 const sponsorTasks = await prisma . sponsor_Task . findMany ( {
0 commit comments