Skip to content

Commit

Permalink
Rename Snowflake.discordEpochStart to Snowflake.discordEpoch
Browse files Browse the repository at this point in the history
  • Loading branch information
lukellmann committed Sep 2, 2021
1 parent 95bd70e commit 957fcc4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
13 changes: 12 additions & 1 deletion common/src/main/kotlin/entity/Snowflake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,18 @@ class Snowflake : Comparable<Snowflake> {
/**
* The point in time that marks the Discord Epoch (the first second of 2015).
*/
val discordEpochStart: Instant = Instant.fromEpochMilliseconds(discordEpochLong)
@Deprecated(
"Snowflake.discordEpochStart was renamed to Snowflake.discordEpoch.",
ReplaceWith("Snowflake.discordEpoch"),
DeprecationLevel.ERROR,
)
val discordEpochStart: Instant
get() = discordEpoch

/**
* The point in time that marks the Discord Epoch (the first second of 2015).
*/
val discordEpoch: Instant = Instant.fromEpochMilliseconds(discordEpochLong)

/**
* The last point in time a Snowflake can represent.
Expand Down
16 changes: 8 additions & 8 deletions common/src/test/kotlin/entity/SnowflakeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import kotlin.test.*
class SnowflakeTest {

@Test
fun `min Snowflake's timeStamp is equal to discordEpochStart`() {
assertEquals(Snowflake.discordEpochStart, Snowflake.min.timeStamp)
fun `min Snowflake's timeStamp is equal to discordEpoch`() {
assertEquals(Snowflake.discordEpoch, Snowflake.min.timeStamp)
}

@Test
Expand All @@ -21,9 +21,9 @@ class SnowflakeTest {
}

@Test
fun `Snowflake created from ULong MIN_VALUE has timeStamp equal to discordEpochStart`() {
fun `Snowflake created from ULong MIN_VALUE has timeStamp equal to discordEpoch`() {
val snowflake = Snowflake(ULong.MIN_VALUE)
assertEquals(Snowflake.discordEpochStart, snowflake.timeStamp)
assertEquals(Snowflake.discordEpoch, snowflake.timeStamp)
}

@Test
Expand All @@ -33,15 +33,15 @@ class SnowflakeTest {
}

@Test
fun `Snowflake created from Long MIN_VALUE has timeStamp equal to discordEpochStart`() {
fun `Snowflake created from Long MIN_VALUE has timeStamp equal to discordEpoch`() {
val snowflake = Snowflake(Long.MIN_VALUE)
assertEquals(Snowflake.discordEpochStart, snowflake.timeStamp)
assertEquals(Snowflake.discordEpoch, snowflake.timeStamp)
}

@Test
fun `Snowflake created from instant far in the past has timeStamp equal to discordEpochStart`() {
fun `Snowflake created from instant far in the past has timeStamp equal to discordEpoch`() {
val snowflake = Snowflake(Instant.DISTANT_PAST)
assertEquals(Snowflake.discordEpochStart, snowflake.timeStamp)
assertEquals(Snowflake.discordEpoch, snowflake.timeStamp)
}

@Test
Expand Down

0 comments on commit 957fcc4

Please sign in to comment.