5.16
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
export const mix = (c1, c2, ratio) => {
|
||||
ratio = Math.max(Math.min(Number(ratio), 1), 0)
|
||||
let r1 = parseInt(c1.substring(1, 3), 16)
|
||||
let g1 = parseInt(c1.substring(3, 5), 16)
|
||||
let b1 = parseInt(c1.substring(5, 7), 16)
|
||||
let r2 = parseInt(c2.substring(1, 3), 16)
|
||||
let g2 = parseInt(c2.substring(3, 5), 16)
|
||||
let b2 = parseInt(c2.substring(5, 7), 16)
|
||||
let r = Math.round(r1 * (1 - ratio) + r2 * ratio) + ''
|
||||
let g = Math.round(g1 * (1 - ratio) + g2 * ratio) + ''
|
||||
let b = Math.round(b1 * (1 - ratio) + b2 * ratio) + ''
|
||||
r = ('0' + (r || 0).toString(16)).slice(-2)
|
||||
g = ('0' + (g || 0).toString(16)).slice(-2)
|
||||
b = ('0' + (b || 0).toString(16)).slice(-2)
|
||||
return '#' + r + g + b
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
export function getDateTime(type) {
|
||||
var date = new Date();
|
||||
var hengGang = "-";
|
||||
var maoHao = ":";
|
||||
var year = date.getFullYear();
|
||||
var month = date.getMonth() + 1;
|
||||
var curDate = date.getDate();
|
||||
var curHours = date.getHours();
|
||||
var curMinutes = date.getMinutes();
|
||||
var curSeconds = date.getSeconds();
|
||||
|
||||
if (month >= 1 && month <= 9) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (curDate >= 0 && curDate <= 9) {
|
||||
curDate = "0" + curDate;
|
||||
}
|
||||
if (curHours >= 0 && curHours <= 9) {
|
||||
curHours = "0" + curHours;
|
||||
}
|
||||
if (curMinutes >= 0 && curMinutes <= 9) {
|
||||
curMinutes = "0" + curMinutes;
|
||||
}
|
||||
if (curSeconds >= 0 && curSeconds <= 9) {
|
||||
curSeconds = "0" + curSeconds;
|
||||
}
|
||||
var currentdate = "";
|
||||
if (type == "year") {
|
||||
currentdate = year;
|
||||
return currentdate;
|
||||
} else if (type == "month") {
|
||||
currentdate = year + hengGang + month;
|
||||
return currentdate;
|
||||
} else {
|
||||
currentdate = year + hengGang + month + hengGang + curDate + " "
|
||||
return currentdate;
|
||||
}
|
||||
}
|
||||
// var year = getDateTime('year');
|
||||
// console.log(year); // 2021
|
||||
// var month = getDateTime('month');
|
||||
// console.log(month); // 12
|
||||
// var date = getDateTime('');
|
||||
// console.log(date); // 2021-12-03 09:00:00
|
||||
Reference in New Issue
Block a user