Skip to content

Commit

Permalink
Extract Discord timestamp conversion to a helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Nov 30, 2024
1 parent 8e50c8f commit 413d1b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/utils/helpers/DateTimeFormatHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ export abstract class DateTimeFormatHelper {
});
}

/**
* Converts a date to a Discord timestamp.
*
* @param date The date to convert.
* @returns The Discord timestamp.
*/
static toDiscordTimestamp(date: Date): `<t:${number}:F>` {
return `<t:${Math.floor(date.getTime() / 1000)}:F>`;
}

/**
* Gets the localization of this helper utility.
*
Expand Down
2 changes: 1 addition & 1 deletion src/utils/managers/BeatmapManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ export abstract class BeatmapManager extends Manager {
case 6:
return `${bold(
"Last Update",
)}: <t:${Math.floor(beatmapInfo.lastUpdate.getTime() / 1000)}:F> | ${bold(
)}: ${DateTimeFormatHelper.toDiscordTimestamp(beatmapInfo.lastUpdate)} | ${bold(
this.convertStatus(beatmapInfo.approved),
)}`;

Expand Down

0 comments on commit 413d1b3

Please sign in to comment.