//日期格式化函数
//Script here
var d = null;
var startDate = null;
var endDate = null;
var tradedate = null;
var lasttradedate = null;
var tradeDateTS = null;
//日期格式化函数
var formatDate = function(dateTime,format){
var fmt = "yyyyMMdd";
if(format != undefined && format != ''){
fmt = format
}
var date = new Date(dateTime);
var o = {
"M+" : date.getMonth()+1, //月份
"d+" : date.getDate(), //日
"h+" : date.getHours(), //小时
"m+" : date.getMinutes(), //分
"s+" : date.getSeconds(), //秒
"q+" : Math.floor((date.getMonth()+3)/3), //季度
"S" : date.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt))
fmt=fmt.replace(RegExp.$1, (date.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;
}
//处理传入参数,如果传入参数为0或为空时取当前机器时间进行计算
if(V_msgBusBeginTime == 0 || V_msgBusBeginTime == '' || V_msgBusBeginTime == null){
d = new Date();
}else{
d = new Date(V_msgBusBeginTime);
}
//d = new Date('2020/10/24');
tradedate = formatDate(d.getTime());
tradeDateTS = formatDate(d.getTime(), 'yyyy-MM-dd 00:00:00.0');
lasttradedate = d.setDate(d.getDate()-1);
lasttradedate = formatDate((new Date(lasttradedate)).getTime());
var cmonth = d.getMonth() + 1;
if(cmonth >= 1 && cmonth <= 3){
startDate = (d.getFullYear() - 1 ) + '-12-30';
endDate = d.getFullYear() + '-03-30';
}else if(cmonth >= 4 && cmonth <= 6){
startDate = d.getFullYear() + '-03-30';
endDate = d.getFullYear() + '-06-30';
}else if(cmonth >= 7 && cmonth <= 9){
startDate = d.getFullYear() + '-06-30';
endDate = d.getFullYear() + '-09-30';
}else{
startDate = d.getFullYear() + '-09-30';
endDate = d.getFullYear() + '-12-31';
}