Skip to content

Commit 8d28cd2

Browse files
committed
jda-ktx: Add TimeFormat.atInstant with kotlin.time.Instant
1 parent c156724 commit 8d28cd2

File tree

1 file changed

+19
-0
lines changed
  • BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/utils

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package dev.freya02.botcommands.jda.ktx.utils
2+
3+
import net.dv8tion.jda.api.utils.TimeFormat
4+
import net.dv8tion.jda.api.utils.Timestamp
5+
import kotlin.time.Instant
6+
import kotlin.time.toJavaInstant
7+
8+
/**
9+
* Converts the provided [Instant] into a [Timestamp] with this style.
10+
*
11+
* @param instant
12+
* The [Instant] for the timestamp
13+
*
14+
* @return The [Timestamp] instance
15+
*
16+
* @see TimeFormat.now
17+
* @see TimeFormat.atTimestamp
18+
*/
19+
fun TimeFormat.atInstant(instant: Instant) = atInstant(instant.toJavaInstant())

0 commit comments

Comments
 (0)