1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/home-zy-cigarette_plugin_library

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
В этом репозитории не указан файл с открытой лицензией (LICENSE). При использовании обратитесь к конкретному описанию проекта и его зависимостям в коде.
Клонировать/Скачать
TimeHelper.js 2.4 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
易支烟 Отправлено 09.09.2019 06:28 442d65f
Date.prototype.MaxDate=function(time){
let sTime=this;
let eTime=time;
typeof eTime==='string'&&(eTime=new Date(time));
sTime=sTime.getTime();
eTime=eTime.getTime();
return sTime>eTime;
};
Date.prototype.MinDate=function(time){
let sTime=this;
let eTime=time;
typeof eTime==='string'&&(eTime=new Date(time));
sTime=sTime.getTime();
eTime=eTime.getTime();
return sTime<eTime;
};
Date.prototype.EqualDate=function(time){
let sTime=this;
let eTime=time;
typeof eTime==='string'&&(eTime=new Date(time));
sTime=sTime.getTime();
eTime=eTime.getTime();
return sTime<eTime;
};
Date.prototype.format = function(fmt){
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt))
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)
if(new RegExp("("+ k +")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
return fmt;
};
Date.prototype.addDay=function(time){
return new Date(this.getTime()+86400000*time);
};
Date.prototype.addHours=function(time){
return new Date(this.getTime()+3600000*time);
};
Date.prototype.addMinutes=function(time){
return new Date(this.getTime()+60000*time);
};
Date.prototype.addSeconds=function(time){
return new Date(this.getTime()+1000*time);
};
Date.prototype.addMonth=function(time){
let date=this;
let monthnum = parseInt(time);
let year = date.getFullYear();
let month =date.getMonth()+1;
let day =date.getDate();
let newyear = year;
let newmonth = month + monthnum;
let newday = day;
if (month + monthnum > 12)
{
newyear = year + 1;
newmonth = month + monthnum - 12;
newday = day;
}
console.log(day);
let addTime=date.getTime()-new Date(year + "-" + month + "-" + day).getTime();
let newdate = new Date(new Date(newyear + "-" + newmonth + "-" + newday).getTime()+addTime);
return newdate;
};
Date.prototype.addYear=function(time){
this.setFullYear(this.getFullYear()+time);
return this;
};
Date.prototype.getWeeksDay=function(){
return ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"][this.getDay()];
};

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/home-zy-cigarette_plugin_library.git
git@api.gitlife.ru:oschina-mirror/home-zy-cigarette_plugin_library.git
oschina-mirror
home-zy-cigarette_plugin_library
home-zy-cigarette_plugin_library
master