Skip to content

Commit 43f0071

Browse files
committed
chore: add comment explaining timestamp conversion
1 parent 0e979a2 commit 43f0071

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/structures/src/utils/optimization.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export function extendTemplate<SuperTemplate extends Record<string, unknown>>(
99
SuperTemplate;
1010
}
1111

12+
/**
13+
* Turns a JavaScript Date object into the timestamp format used by Discord in payloads.
14+
* E.g. `2025-11-16T14:09:25.239000+00:00`
15+
*
16+
* @private
17+
* @param date a Date instance
18+
* @returns an ISO8601 timestamp with microseconds precision and explicit +00:00 timezone
19+
*/
1220
export function dateToDiscordISOTimestamp(date: Date) {
1321
return `${date.getUTCFullYear()}-${(date.getUTCMonth() + 1).toString().padStart(2, '0')}-${date.getUTCDate().toString().padStart(2, '0')}T${date.getUTCHours().toString().padStart(2, '0')}:${date.getUTCMinutes().toString().padStart(2, '0')}:${date.getUTCSeconds().toString().padStart(2, '0')}.${date.getUTCMilliseconds().toString().padEnd(6, '0')}+00:00`;
1422
}

0 commit comments

Comments
 (0)