fix(server): IdService.parseを全てのidタイプに対応させるように (#10533)
* wip fix-id
* ✌️
* fix import
This commit is contained in:
@@ -3,6 +3,7 @@ const CHARS = '0123456789abcdef';
|
||||
// 4bit Fixed hex value 'g'
|
||||
// 44bit UNIX Time ms in Hex
|
||||
// 48bit Random value in Hex
|
||||
export const meidgRegExp = /^g[0-9a-f]{23}$/;
|
||||
|
||||
function getTime(time: number) {
|
||||
if (time < 0) time = 0;
|
||||
@@ -26,3 +27,9 @@ function getRandom() {
|
||||
export function genMeidg(date: Date): string {
|
||||
return 'g' + getTime(date.getTime()) + getRandom();
|
||||
}
|
||||
|
||||
export function parseMeidg(id: string): { date: Date; } {
|
||||
return {
|
||||
date: new Date(parseInt(id.slice(1, 12), 16)),
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user