All files / str getTime36.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                      1x 2x 2x     1x  
/**
 * 获取36进制日期字符串
 * @method getTime36
 * @param {Date} [date] 符合规范的日期字符串或者数字,不传参数则使用当前客户端时间
 * @return {String} 转成为36进制的字符串
 * @example
 * import { getTime36 } from '@spore-ui/tskit';
 * getTime36('2020'); // 'k4ujaio0'
 */
import { TypeDate } from '../types';
 
export function getTime36(date?: TypeDate): string {
  const dvalue = date ? new Date(date).getTime() : new Date().getTime();
  return dvalue.toString(36);
}
 
export default getTime36;