mp-colorui
Version:
MP ColorUI 是一款基于 Taro 框架并且联合 Color-UI CSS 库开发的多端 UI 组件库(目前仅支持小程序端)
28 lines • 761 B
JavaScript
import * as model from "./model";
const fullDate = num => {
if (num < 10) return '0' + num;
return num;
};
export const getNowDate = type => {
const date = new Date();
const year = date.getFullYear();
const month = fullDate(date.getMonth());
const day = fullDate(date.getDate());
if (type === 'year') return `${year}`;
if (type === 'month') return `${year}-${month}`;
if (type === 'day') return `${year}-${month}-${day}`;
return `${year}-${month}-${day}`;
};
export const getNowTIme = () => {
const date = new Date();
const hour = date.getHours();
const min = date.getMinutes();
return `${hour}:${min}`;
};
export default {
model,
getNowDate
};
export const isNumber = obj => {
return typeof obj === 'number' && !isNaN(obj);
};