All files / str getTime36.js

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

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                      3x 3x     1x  
/**
 * 获取36进制日期字符串
 * @method str/getTime36
 * @param {Date} [date] 符合规范的日期字符串或者数字,不传参数则使用当前客户端时间
 * @return {String} 转成为36进制的字符串
 * @example
 * var $getTime36 = require('@spore-ui/kit/packages/str/getTime36');
 * $getTime36('2020'); // 'k4ujaio0'
 */
 
function getTime36(date) {
  date = date ? new Date(date) : new Date();
  return date.getTime().toString(36);
}
 
module.exports = getTime36;