nextjs-rewrite (#5)
Reviewed-on: #5 Co-authored-by: David Gwilliam <dhgwilliam@gmail.com> Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Tournament utility functions
|
||||
* Used for calculating dynamic tournament status based on event date
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calculates the tournament status based on the event date
|
||||
* @param eventDate - The date of the tournament event
|
||||
* @returns The calculated status string: "planned" or "completed"
|
||||
*/
|
||||
export function getTournamentStatus(eventDate: Date | null): string {
|
||||
if (!eventDate) {
|
||||
return "planned";
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const eventDateObj = new Date(eventDate);
|
||||
|
||||
// If event date is in the past, it's completed
|
||||
if (eventDateObj < now) {
|
||||
return "completed";
|
||||
}
|
||||
|
||||
// If event date is today or in the future, it's planned
|
||||
return "planned";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a tournament date is in the past
|
||||
* @param eventDate - The date of the tournament event
|
||||
* @returns true if the event date is in the past, false otherwise
|
||||
*/
|
||||
export function isTournamentPast(eventDate: Date | null): boolean {
|
||||
if (!eventDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const eventDateObj = new Date(eventDate);
|
||||
return eventDateObj < now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a tournament date is in the future
|
||||
* @param eventDate - The date of the tournament event
|
||||
* @returns true if the event date is in the future, false otherwise
|
||||
*/
|
||||
export function isTournamentFuture(eventDate: Date | null): boolean {
|
||||
if (!eventDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const eventDateObj = new Date(eventDate);
|
||||
return eventDateObj > now;
|
||||
}
|
||||
Reference in New Issue
Block a user