feat(SnowflakeUtil): add timestampFrom (#7058)

This commit is contained in:
Antonio Román
2021-12-06 08:56:29 +01:00
committed by GitHub
parent 1c93faa3ab
commit 8b200c0fee
19 changed files with 27 additions and 17 deletions

View File

@@ -70,6 +70,15 @@ class SnowflakeUtil extends null {
};
}
/**
* Retrieves the timestamp field's value from a Discord snowflake.
* @param {Snowflake} snowflake Snowflake to get the timestamp value from
* @returns {number}
*/
static timestampFrom(snowflake) {
return Number(BigInt(snowflake) >> 22n) + EPOCH;
}
/**
* Discord's epoch value (2015-01-01T00:00:00.000Z).
* @type {number}