Skip to content

Commit

Permalink
chore: current date outsourced
Browse files Browse the repository at this point in the history
  • Loading branch information
berenteb committed Feb 28, 2024
1 parent 7dcfd0e commit 49a93be
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions utils/presentation.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ import { differenceInMinutes, isAfter, isBefore } from 'date-fns';

import { PresentationDto } from '../types/conference-api.type';

const currentDate = new Date();

export function isPresentationPast(presentation: PresentationDto) {
const now = new Date();
const now = currentDate;
const end = new Date(presentation.endTime);
return isBefore(end, now);
}

export function isPresentationCurrent(presentation: PresentationDto) {
const now = new Date();
const now = currentDate;
const start = new Date(presentation.startTime);
const end = new Date(presentation.endTime);
return isBefore(start, now) && isAfter(end, now);
}

export function isPresentationUpcoming(presentation: PresentationDto) {
const now = new Date();
const now = currentDate;
const start = new Date(presentation.startTime);
return isAfter(start, now) && differenceInMinutes(start, now) < 15;
}

0 comments on commit 49a93be

Please sign in to comment.