Skip to content

Commit

Permalink
Fix Snowflake.timeMark passing unadjusted milliseconds since Discord …
Browse files Browse the repository at this point in the history
…Epoch to SnowflakeMark's constructor by using same math as Snowflake.timeStamp.

Example where this comes up: Snowflake(Clock.System.now()).timeMark.elapsedNow() should return a very short duration, but did not before.
  • Loading branch information
lukellmann committed Aug 24, 2021
1 parent b0bafb8 commit 86d1412
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion common/src/main/kotlin/entity/Snowflake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Snowflake(val value: Long) : Comparable<Snowflake> {

val timeStamp: Instant get() = Instant.fromEpochMilliseconds(discordEpochLong + (value shr 22))

val timeMark: TimeMark get() = SnowflakeMark(value shr 22)
val timeMark: TimeMark get() = SnowflakeMark(discordEpochLong + (value shr 22))

override fun compareTo(other: Snowflake): Int = value.shr(22).compareTo(other.value.shr(22))

Expand Down

0 comments on commit 86d1412

Please sign in to comment.