1234567891011121314151617181920212223242526272829303132333435363738394041 |
- function formatTime (time) {
- var h = Math.floor(time / 60 /60)
- var s = Math.floor(time / 60)
- var t = time % 60 % 60
- return (h>9?h:'0'+h)+':'+(s>9?s:'0'+s)+':'+(t>9?t:'0'+t)
- }
- function valueOf (time=null) {
- var regexp = getRegExp('-','g');
- var t = time ? (getDate(time).valueOf() || getDate(time.replace(regexp,'/')).valueOf()) : getDate().valueOf()
- return t
- }
- function isIncludes (val,str) {
- return val && val.indexOf(str)!==-1
- }
- function toFixed (val,num) {
- return val.toFixed(num)
- }
- function shuffle(arr) {
- for (var i=arr.length-1; i>=0; i--) {
- var rIndex = Math.floor(Math.random()*(i+1));
- // 打印交换值
- // console.log(i, rIndex);
- var temp = arr[rIndex];
- arr[rIndex] = arr[i];
- arr[i] = temp;
- }
- return arr;
- }
- module.exports = {
- formatTime: formatTime,
- valueOf: valueOf,
- shuffle: shuffle,
- toFixed: toFixed,
- isIncludes: isIncludes
- }
|