feat: 用户会话旧在线用户
This commit is contained in:
@@ -60,13 +60,15 @@ export function parseDatePath(date: number | Date = Date.now()): string {
|
||||
* 判断两次时间差
|
||||
* @param endDate 结束时间
|
||||
* @param startDate 开始时间
|
||||
* @returns 单位秒
|
||||
* @param unit 单位
|
||||
* @returns 单位数值
|
||||
*/
|
||||
export function diffSeconds(
|
||||
endDate: number | Date,
|
||||
startDate: number | Date
|
||||
export function diffValue(
|
||||
endDate: string | number | Date,
|
||||
startDate: string | number | Date,
|
||||
unit: 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year'
|
||||
): number {
|
||||
const value = Math.ceil(dayjs(endDate).diff(startDate, 'seconds'));
|
||||
const value = Math.ceil(dayjs(endDate).diff(startDate, unit));
|
||||
if (Number.isNaN(value)) return 0;
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user