overleaf/services/web/frontend/js/features/subscription/util/free-trial-expires-under-seven-days.ts

12 lines
339 B
TypeScript
Raw Normal View History

export default function freeTrialExpiresUnderSevenDays(
trialEndsAt?: string | null
) {
if (!trialEndsAt) return false
const sevenDaysTime = new Date()
sevenDaysTime.setDate(sevenDaysTime.getDate() + 7)
const freeTrialEndDate = new Date(trialEndsAt)
return new Date() < freeTrialEndDate && freeTrialEndDate < sevenDaysTime
}