/**
* @Memo
*
* @Author songyf
* @Date Aug 22,2019
*
* @Readme :eg: $("#id").html(plugin.convertTime("2019-08-23 15:00:00"));
$("#id").html(plugin.convertTime(new Date()));
$("#id").html(plugin.convertTime(new Date("2019-08-21")));
......
*/
;(function(win,undefined) {
"use strict"
var _win;
var plugin = {
/**
* : 【 、1 、 ...】
* @param e
* @param t
* @returns
*/
convertTime: function(e , t) {
var i = this,
o = [[], []],
a = (new Date).getTime() - new Date(e).getTime();
return a > 6912e5 ? (a = new Date(e), o[0][0] = i.digit(a.getFullYear(), 4), o[0][1] = i.digit(a.getMonth() + 1), o[0][2] = i.digit(a.getDate()), t || (o[1][0] = i.digit(a.getHours()), o[1][1] = i.digit(a.getMinutes()), o[1][2] = i.digit(a.getSeconds())), o[0].join("-") + " " + o[1].join(":")) : a >= 864e5 ? (a / 1e3 / 60 / 60 / 24 | 0) + " ": a >= 36e5 ? (a / 1e3 / 60 / 60 | 0) + " ": a >= 12e4 ? (a / 1e3 / 60 | 0) + " ": a < 0 ? " ": " "
},
digit: function(e, t) {
var i = "";
e = String(e),
t = t || 2;
for (var o = e.length; o < t; o++) i += "0";
return e < Math.pow(10, t) ? i + (0 | e) : e
},
}
//
_win = (function(){ return this || (0, eval)('this'); }());
!('plugin' in _win) && (_win.plugin = plugin);
}());