javascript_距离过年还有多少天_ZHOU125disorder_

本文介绍如何使用JavaScript编写代码来计算距离过年还有多少天,通过日期运算展示实时的倒计时效果。
摘要由CSDN通过智能技术生成

春节倒计时

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>距离春节倒计时</title>
</head>
<body>
    <script>
        console.log("距离春节还有多少天倒计时");
        var time=new Date();
        console.log(time);
        console.log(time.toLocaleString());
        console.log(time.toLocaleDateString());
        console.log(time.getFullYear());
        console.log(time.getMonth());
        console.log(time.getDate());
        console.log(time.getHours());
        console.log(time.getMinutes());
        console.log(time.getSeconds());
        console.log(time.getMilliseconds());
        console.log(time.getDay());
        console.log("------------");
        var newYear=new Date("2021/2/12 00:00");
        var value=newYear-time;
        console.log("距离2021春节还有"+value+"毫秒");
        console.log("距离2021春节还有"+parseInt(value/1000)+"秒");
        console.log("距离2021春节还有"+parseInt(value/1000/60)+"分钟");
        console.log("距离2021春节还有"+parseInt(value/1000/60/60)+"小时");
        console.log("距离2021春节还有"+parseInt(value/1000/60/60/24)+"天");
        console.log("距离2021春节还有"+value/1000/60/60/24/30+"个月");
        document.write("距离2021还有"+parseInt(value/1000/60/60/24)+"天"+parseInt(value/1000/60/60%24)+"小时"
        +parseInt(value/1000/60%60)+"分钟"+parseInt(value/1000%60)+"秒"+parseInt(value%1000)+"毫秒");
    </script>
</body>
</html>
请解释分析下面这段程序:%%%无序充电投标 clear clc load data_disorder Pch=[Pch_CS1_disorder;Pch_CS2_disorder;Pch_CS3_disorder;Pch_CS4_disorder];%充电站充电功率 %市场出清问题 Link=zeros(24,96);%时段换算矩阵(日前1h换算为实时15min) for i=1:24 Link(i,4*i-3:4*i)=1; end Loadcurve=[0.955391944564747,0.978345604157644,1,0.995019488956258,0.972932005197055,0.970333477695972,0.930489389346037,0.890428757037679,0.902771762667822,0.941966219142486,0.911000433087917,0.862061498484192,0.840190558683413,0.831095712429623,0.756604590731919,0.671719359029883,0.611520138588133,0.582936336076224,0.572542226071893,0.574707665656128,0.587267215244695,0.644218276310091,0.755521870939801,0.884798614118666]; Loadcurve=Loadcurve*Link;%换成96个时段 PL_base=[5.704;5.705;5.631;6.518;4.890;5.705;5.847]*1000;%负荷分布 PL=PL_base*Loadcurve;%基础负荷(负荷曲线从08:00开始算起,即第9个时段) Pf=sdpvar(7,96);%馈线功率 Pf(1,:)=PL(1,:)+Pch(1,:);Pf(2,:)=PL(2,:);Pf(3,:)=PL(3,:);Pf(4,:)=PL(4,:)+Pch(2,:);Pf(5,:)=PL(5,:)+Pch(3,:);Pf(6,:)=PL(6,:);Pf(7,:)=PL(7,:)+Pch(4,:);%馈线功率组成 Pg=sdpvar(10,96);%发电商分段电量 Pg_step=1000*[20,5,3,2,2,2,2,2,2,inf]';%报价区间 Price_DSO=[3:12]'*0.1;%分段电价 Obj=0.25*sum(sum((Price_DSO*ones(1,96)).*Pg));%目标为用电费用最小 Constraint=[0<=Pg<=Pg_step*ones(1,96),sum(Pg)==sum(Pf)];%约束条件 optimize(Constraint,Obj);%求解线性规划问题 Pg=double(Pg);%发电机功率 Pf=double(Pf);%馈线功率 isPg=(Pg>0);%为了计算出清电价,计算发电机分段选择情况 DLMP=sum(isPg)/10+0.2;%出清电价计算 %绘图 figure(1)%节点边际电价 stairs(DLMP); xlabel 时间 ylabel 电价(元/kWh) ylim([0.3,1.3]) figure(2)%负荷曲线 hold on plot(sum(PL)/1000); plot(sum(Pf)/1000,'r.-'); xlabel 时间 ylabel 负荷(MW) legend('基础负荷','无序充电负荷') Cost=sum(sum(Pch).*DLMP);%总用电费用 result_disorder.Cost=Cost;result_disorder.DLMP=DLMP;result_disorder.Pf=Pf;result_disorder.Pg=Pg;%结果保存 save('result_disorder','result_disorder');
最新发布
06-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值