st-common-core
Version:
小尾巴前端通用核心库
24 lines (23 loc) • 651 B
TypeScript
/**
* 时间单位字符串名称常量对象
*/
export declare const TimeUnit: {
readonly millisecond: "millisecond";
readonly second: "second";
readonly minute: "minute";
readonly hour: "hour";
readonly day: "day";
};
/**
* 时间单位类型
*/
export type TimeUnitType = typeof TimeUnit[keyof typeof TimeUnit];
/**
* 时间单位转换
*
* @param {number} time 时间值
* @param {TimeUnit} fromUnit 源单位
* @param {TimeUnit} toUnit 目标单位,默认为秒
* @returns {number} 目标单位的时间值
*/
export declare const convert: (time: number, fromUnit: TimeUnitType, toUnit?: TimeUnitType) => number;