utils/ts-src/minuteFloor.ts

16 lines
373 B
TypeScript

/**
* Get the minute floor as a Base 32 string
* @param timestamp The timestamp as a number
* @returns {string}
*
* @example
* U.minuteFloor(1605532173) // => '1fnp540'
*/
export function minuteFloor(timestamp?: number|null): string {
const _timestamp = (timestamp) ? timestamp : Date.now();
return (Math.floor(_timestamp / 60000) * 60000).toString(32);
}