发布时间:2013-11-25 22:16:52作者:知识屋
作者:Xiao_Bo_Ben
[javascript]
var MrYangUtil=function(){
this.getCurrentDate=function(){
return new Date();
};
this.getCurrentWeek=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//返回date是一周中的某一天
var week=currentDate.getDay();
//返回date是一个月中的某一天
var month=currentDate.getDate();
//一天的毫秒数
var millisecond=1000*60*60*24;
//减去的天数
var minusDay=week!=0?week-1:6;
//alert(minusDay);
//本周 周一
var monday=newDate(currentDate.getTime()-(minusDay*millisecond));
//本周 周日
var sunday=newDate(monday.getTime()+(6*millisecond));
//添加本周时间
startStop.push(monday);//本周起始时间
//添加本周最后一天时间
startStop.push(sunday);//本周终止时间
//返回
return startStop;
};
this.getCurrentMonth=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前月份0-11
var currentMonth=currentDate.getMonth();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//求出本月第一天
var firstDay=newDate(currentYear,currentMonth,1);
//当为12月的时候年份需要加1
//月份需要更新为0 也就是下一年的第一个月
if(currentMonth==11){
currentYear++;
currentMonth=0;//就为
}else{
//否则只是月份增加,以便求的下一月的第一天
currentMonth++;
}
//一天的毫秒数
var millisecond=1000*60*60*24;
//下月的第一天
var nextMonthDayOne=newDate(currentYear,currentMonth,1);
//求出上月的最后一天
var lastDay=newDate(nextMonthDayOne.getTime()-millisecond);
//添加至数组中返回
startStop.push(firstDay);
startStop.push(lastDay);
//返回
return startStop;
};
this.getQuarterSeasonStartMonth=function(month){
var quarterMonthStart=0;
var spring=0; //春
var summer=3; //夏
var fall=6; //秋
var winter=9;//冬
//月份从0-11
if(month<3){
return spring;
}
if(month<6){
return summer;
}
if(month<9){
return fall;
}
return winter;
};
this.getMonthDays=function(year,month){
//本月第一天 1-31
var relativeDate=new Date(year,month,1);
//获得当前月份0-11
var relativeMonth=relativeDate.getMonth();
//获得当前年份4位年
varrelativeYear=relativeDate.getFullYear();
//当为12月的时候年份需要加1
//月份需要更新为0 也就是下一年的第一个月
if(relativeMonth==11){
relativeYear++;
relativeMonth=0;
}else{
//否则只是月份增加,以便求的下一月的第一天
relativeMonth++;
}
//一天的毫秒数
var millisecond=1000*60*60*24;
//下月的第一天
var nextMonthDayOne=newDate(relativeYear,relativeMonth,1);
//返回得到上月的最后一天,也就是本月总天数
return newDate(nextMonthDayOne.getTime()-millisecond).getDate();
};
this.getCurrentSeason=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前月份0-11
var currentMonth=currentDate.getMonth();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//获得本季度开始月份
varquarterSeasonStartMonth=this.getQuarterSeasonStartMonth(currentMonth);
//获得本季度结束月份
varquarterSeasonEndMonth=quarterSeasonStartMonth+2;
//获得本季度开始的日期
var quarterSeasonStartDate=newDate(currentYear,quarterSeasonStartMonth,1);
//获得本季度结束的日期
var quarterSeasonEndDate=newDate(currentYear,quarterSeasonEndMonth,this.getMonthDays(currentYear,quarterSeasonEndMonth));
//加入数组返回
startStop.push(quarterSeasonStartDate);
startStop.push(quarterSeasonEndDate);
//返回
return startStop;
};
this.getCurrentYear=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//本年第一天
var currentYearFirstDate=newDate(currentYear,0,1);
//本年最后一天
var currentYearLastDate=newDate(currentYear,11,31);
//添加至数组
startStop.push(currentYearFirstDate);
startStop.push(currentYearLastDate);
//返回
return startStop;
};
this.getPriorMonthFirstDay=function(year,month){
//年份为0代表,是本年的第一月,所以不能减
if(month==0){
month=11;//月份为上年的最后月份
year--;//年份减1
return new Date(year,month,1);
}
//否则,只减去月份
month--;
return new Date(year,month,1);;
};
this.getPreviousMonth=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前月份0-11
var currentMonth=currentDate.getMonth();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//获得上一个月的第一天
varpriorMonthFirstDay=this.getPriorMonthFirstDay(currentYear,currentMonth);
//获得上一月的最后一天
var priorMonthLastDay=newDate(priorMonthFirstDay.getFullYear(),priorMonthFirstDay.getMonth(),this.getMonthDays(priorMonthFirstDay.getFullYear(),priorMonthFirstDay.getMonth()));
//添加至数组
startStop.push(priorMonthFirstDay);
startStop.push(priorMonthLastDay);
//返回
return startStop;
};
this.getPreviousWeek=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//返回date是一周中的某一天
var week=currentDate.getDay();
//返回date是一个月中的某一天
var month=currentDate.getDate();
//一天的毫秒数
var millisecond=1000*60*60*24;
//减去的天数
var minusDay=week!=0?week-1:6;
//获得当前周的第一天
var currentWeekDayOne=newDate(currentDate.getTime()-(millisecond*minusDay));
//上周最后一天即本周开始的前一天
var priorWeekLastDay=newDate(currentWeekDayOne.getTime()-millisecond);
//上周的第一天
var priorWeekFirstDay=newDate(priorWeekLastDay.getTime()-(millisecond*6));
//添加至数组
startStop.push(priorWeekFirstDay);
startStop.push(priorWeekLastDay);
return startStop;
};
this.getPriorSeasonFirstDay=function(year,month){
var quarterMonthStart=0;
var spring=0; //春
var summer=3; //夏
var fall=6; //秋
var winter=9;//冬
//月份从0-11
switch(month){//季度的其实月份
case spring:
//如果是第一季度则应该到去年的冬季
year--;
month=winter;
break;
case summer:
month=spring;
break;
case fall:
month=summer;
break;
case winter:
month=fall;
break;
};
return new Date(year,month,1);
};
this.getPreviousSeason=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前月份0-11
var currentMonth=currentDate.getMonth();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//上季度的第一天
var priorSeasonFirstDay=this.getPriorSeasonFirstDay(currentYear,currentMonth);
//上季度的最后一天
var priorSeasonLastDay=newDate(priorSeasonFirstDay.getFullYear(),priorSeasonFirstDay.getMonth()+2,this.getMonthDays(priorSeasonFirstDay.getFullYear(),priorSeasonFirstDay.getMonth()+2));
//添加至数组
startStop.push(priorSeasonFirstDay);
startStop.push(priorSeasonLastDay);
return startStop;
};
this.getPreviousYear=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
currentYear--;
var priorYearFirstDay=newDate(currentYear,0,1);
var priorYearLastDay=newDate(currentYear,11,1);
//添加至数组
startStop.push(priorYearFirstDay);
startStop.push(priorYearLastDay);
return startStop;
};
};
var MrYangUtil=function(){
this.getCurrentDate=function(){
return new Date();
};
this.getCurrentWeek=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//返回date是一周中的某一天
var week=currentDate.getDay();
//返回date是一个月中的某一天
var month=currentDate.getDate();
//一天的毫秒数
var millisecond=1000*60*60*24;
//减去的天数
var minusDay=week!=0?week-1:6;
//alert(minusDay);
//本周 周一
var monday=newDate(currentDate.getTime()-(minusDay*millisecond));
//本周 周日
var sunday=newDate(monday.getTime()+(6*millisecond));
//添加本周时间
startStop.push(monday);//本周起始时间
//添加本周最后一天时间
startStop.push(sunday);//本周终止时间
//返回
return startStop;
};
this.getCurrentMonth=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前月份0-11
var currentMonth=currentDate.getMonth();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//求出本月第一天
var firstDay=newDate(currentYear,currentMonth,1);
//当为12月的时候年份需要加1
//月份需要更新为0 也就是下一年的第一个月
if(currentMonth==11){
currentYear++;
currentMonth=0;//就为
}else{
//否则只是月份增加,以便求的下一月的第一天
currentMonth++;
}
//一天的毫秒数
var millisecond=1000*60*60*24;
//下月的第一天
var nextMonthDayOne=newDate(currentYear,currentMonth,1);
//求出上月的最后一天
var lastDay=newDate(nextMonthDayOne.getTime()-millisecond);
//添加至数组中返回
startStop.push(firstDay);
startStop.push(lastDay);
//返回
return startStop;
};
this.getQuarterSeasonStartMonth=function(month){
var quarterMonthStart=0;
var spring=0; //春
var summer=3; //夏
var fall=6; //秋
var winter=9;//冬
//月份从0-11
if(month<3){
return spring;
}
if(month<6){
return summer;
}
if(month<9){
return fall;
}
return winter;
};
this.getMonthDays=function(year,month){
//本月第一天 1-31
var relativeDate=new Date(year,month,1);
//获得当前月份0-11
var relativeMonth=relativeDate.getMonth();
//获得当前年份4位年
varrelativeYear=relativeDate.getFullYear();
//当为12月的时候年份需要加1
//月份需要更新为0 也就是下一年的第一个月
if(relativeMonth==11){
relativeYear++;
relativeMonth=0;
}else{
//否则只是月份增加,以便求的下一月的第一天
relativeMonth++;
}
//一天的毫秒数
var millisecond=1000*60*60*24;
//下月的第一天
var nextMonthDayOne=newDate(relativeYear,relativeMonth,1);
//返回得到上月的最后一天,也就是本月总天数
return newDate(nextMonthDayOne.getTime()-millisecond).getDate();
};
this.getCurrentSeason=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前月份0-11
var currentMonth=currentDate.getMonth();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//获得本季度开始月份
varquarterSeasonStartMonth=this.getQuarterSeasonStartMonth(currentMonth);
//获得本季度结束月份
varquarterSeasonEndMonth=quarterSeasonStartMonth+2;
//获得本季度开始的日期
var quarterSeasonStartDate=newDate(currentYear,quarterSeasonStartMonth,1);
//获得本季度结束的日期
var quarterSeasonEndDate=newDate(currentYear,quarterSeasonEndMonth,this.getMonthDays(currentYear,quarterSeasonEndMonth));
//加入数组返回
startStop.push(quarterSeasonStartDate);
startStop.push(quarterSeasonEndDate);
//返回
return startStop;
};
this.getCurrentYear=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//本年第一天
var currentYearFirstDate=newDate(currentYear,0,1);
//本年最后一天
var currentYearLastDate=newDate(currentYear,11,31);
//添加至数组
startStop.push(currentYearFirstDate);
startStop.push(currentYearLastDate);
//返回
return startStop;
};
this.getPriorMonthFirstDay=function(year,month){
//年份为0代表,是本年的第一月,所以不能减
if(month==0){
month=11;//月份为上年的最后月份
year--;//年份减1
return newDate(year,month,1);
}
//否则,只减去月份
month--;
return new Date(year,month,1);;
};
this.getPreviousMonth=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前月份0-11
var currentMonth=currentDate.getMonth();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//获得上一个月的第一天
varpriorMonthFirstDay=this.getPriorMonthFirstDay(currentYear,currentMonth);
//获得上一月的最后一天
var priorMonthLastDay=newDate(priorMonthFirstDay.getFullYear(),priorMonthFirstDay.getMonth(),this.getMonthDays(priorMonthFirstDay.getFullYear(),priorMonthFirstDay.getMonth()));
//添加至数组
startStop.push(priorMonthFirstDay);
startStop.push(priorMonthLastDay);
//返回
return startStop;
};
this.getPreviousWeek=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//返回date是一周中的某一天
var week=currentDate.getDay();
//返回date是一个月中的某一天
var month=currentDate.getDate();
//一天的毫秒数
var millisecond=1000*60*60*24;
//减去的天数
var minusDay=week!=0?week-1:6;
//获得当前周的第一天
var currentWeekDayOne=newDate(currentDate.getTime()-(millisecond*minusDay));
//上周最后一天即本周开始的前一天
var priorWeekLastDay=newDate(currentWeekDayOne.getTime()-millisecond);
//上周的第一天
var priorWeekFirstDay=newDate(priorWeekLastDay.getTime()-(millisecond*6));
//添加至数组
startStop.push(priorWeekFirstDay);
startStop.push(priorWeekLastDay);
return startStop;
};
this.getPriorSeasonFirstDay=function(year,month){
var quarterMonthStart=0;
var spring=0; //春
var summer=3; //夏
var fall=6; //秋
var winter=9;//冬
//月份从0-11
switch(month){//季度的其实月份
case spring:
//如果是第一季度则应该到去年的冬季
year--;
month=winter;
break;
case summer:
month=spring;
break;
case fall:
month=summer;
break;
case winter:
month=fall;
break;
};
return new Date(year,month,1);
};
this.getPreviousSeason=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前月份0-11
var currentMonth=currentDate.getMonth();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
//上季度的第一天
varpriorSeasonFirstDay=this.getPriorSeasonFirstDay(currentYear,currentMonth);
//上季度的最后一天
var priorSeasonLastDay=newDate(priorSeasonFirstDay.getFullYear(),priorSeasonFirstDay.getMonth()+2,this.getMonthDays(priorSeasonFirstDay.getFullYear(),priorSeasonFirstDay.getMonth()+2));
//添加至数组
startStop.push(priorSeasonFirstDay);
startStop.push(priorSeasonLastDay);
return startStop;
};
this.getPreviousYear=function(){
//起止日期数组
var startStop=new Array();
//获取当前时间
var currentDate=this.getCurrentDate();
//获得当前年份4位年
var currentYear=currentDate.getFullYear();
currentYear--;
var priorYearFirstDay=newDate(currentYear,0,1);
var priorYearLastDay=newDate(currentYear,11,1);
//添加至数组
startStop.push(priorYearFirstDay);
startStop.push(priorYearLastDay);[!--empirenews.page--]分页标题[/!--empirenews.page--]
return startStop;
};
};
2014-11-19
怎么找回退出的QQ群的群号?
Winpcap是什么 Winpcap有什么用?
jsp文件怎么打开?
百度权重之我见~ 百度权重的等级划分
DEDE关于列表页分页和内容页分页与CSS不对应,错位的问题-DedeCM
怎样去掉dedecms【织梦】后台的安全提示?
帝国CMS 后台在线编辑CSS扩展修改教程!(建议收藏)
修改Dede友情链接dede:flink
nginx做下载服务器配置一例