Skip to content

Commit 94d306c

Browse files
committed
fix: updated to use constant from dateFormatting
1 parent 04b4196 commit 94d306c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/components/Payroll/helpers.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { PayrollType } from './PayrollList/types'
1313
import { formatPayRate } from '@/helpers/formattedStrings'
1414
import { useLocale } from '@/contexts/LocaleProvider/useLocale'
1515
import { COMPENSATION_NAME_REIMBURSEMENT, FlsaStatus } from '@/shared/constants'
16-
16+
import { MS_PER_HOUR } from '@/helpers/dateFormatting'
1717
const REGULAR_HOURS_NAME = 'regular hours'
1818

1919
// Utility to get the primary job from an employee
@@ -635,10 +635,8 @@ export const canCancelPayroll = (payroll: Payroll): boolean => {
635635
const now = new Date()
636636
const deadline = new Date(payroll.payrollDeadline)
637637

638-
const nowInPT = new Date(now.getTime() + getPacificTimeOffset(now) * 60 * 60 * 1000)
639-
const deadlineInPT = new Date(
640-
deadline.getTime() + getPacificTimeOffset(deadline) * 60 * 60 * 1000,
641-
)
638+
const nowInPT = new Date(now.getTime() + getPacificTimeOffset(now) * MS_PER_HOUR)
639+
const deadlineInPT = new Date(deadline.getTime() + getPacificTimeOffset(deadline) * MS_PER_HOUR)
642640

643641
const cutoffTime = new Date(deadlineInPT)
644642
cutoffTime.setUTCHours(16, 0, 0, 0)

src/helpers/dateFormatting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export const normalizeDateToLocal = (date: Date | null): Date | null => {
200200
return new Date(year, month - 1, day)
201201
}
202202

203-
const MS_PER_HOUR = 1000 * 60 * 60
203+
export const MS_PER_HOUR = 1000 * 60 * 60
204204
const MS_PER_DAY = MS_PER_HOUR * 24
205205

206206
export const getHoursUntil = (deadline?: Date | string | null): number | null => {

0 commit comments

Comments
 (0)