44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
package com.discord.utilities;
|
|
|
|
import d0.g0.s;
|
|
import d0.z.d.m;
|
|
/* compiled from: SnowflakeUtils.kt */
|
|
public final class SnowflakeUtils {
|
|
public static final long DISCORD_EPOCH = 1420070400000L;
|
|
public static final SnowflakeUtils INSTANCE = new SnowflakeUtils();
|
|
public static final int SNOWFLAKE_TIMESTAMP_SHIFT = 22;
|
|
|
|
private SnowflakeUtils() {
|
|
}
|
|
|
|
public static final long atPreviousMillisecond(long j) {
|
|
return (((j >>> 22) - 1) - DISCORD_EPOCH) << 22;
|
|
}
|
|
|
|
public static final long fromTimestamp(long j) {
|
|
return (j - DISCORD_EPOCH) << 22;
|
|
}
|
|
|
|
public static final long getTimestampPart(long j) {
|
|
return j >>> 22;
|
|
}
|
|
|
|
public static /* synthetic */ void getTimestampPart$annotations(long j) {
|
|
}
|
|
|
|
public static final long toTimestamp(long j) {
|
|
return (j >>> 22) + DISCORD_EPOCH;
|
|
}
|
|
|
|
public final Long toSnowflake(String str) {
|
|
m.checkNotNullParameter(str, "$this$toSnowflake");
|
|
Long longOrNull = s.toLongOrNull(str);
|
|
if (longOrNull != null) {
|
|
if (longOrNull.longValue() > DISCORD_EPOCH) {
|
|
return longOrNull;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|