标题: [日期时间] 批处理倒计时 [打印本页]
作者: plp626 时间: 2012-4-21 17:08 标题: 批处理倒计时
本帖最后由 plp626 于 2012-4-21 17:11 编辑
- @echo off||倒计时;
- :: 备份自用 code by plp
-
- if "%1"==":timeout" goto%1
-
- start/b %~fs0 :timeout "2015-1-1"
-
- cmd /k "prompt=-$g$s&echo 获取帮助请键入 help "
- exit
-
- :timeout
- set dates=%date%
- call edate "%dates:~0,10%" "%~2" xx
- set/a xx-=1
- :lp
- call:time2i "%time%" i&call:i2time 8640000-i hfs
- title 现在距离 %~2 还有 %xx%天 零 %hfs% 秒
- goto:lp
-
- :time2i <time> <rt>
- setlocal&set t=%~1
- set/a w=1%t:~-2%,s=1%t:~-5,2%,f=1%t:~-8,2%,h=1%t:~-11,2%
- set/a w-=100,s-=100,f-=100,h-=100,i=h*3600+f*60+s,i=i*100+w
- endlocal&(if %2.==. (echo %i%)else set %2=%i%)&goto:eof
- :i2time <i> <hour> <minute> <second> <perseconde>
- setlocal&set/a t=%1
- set/a w=t%%100,t/=100,h=t/3600,t%%=3600,f=t/60,t%%=60,s=t
- for %%a in (%w%.w,%s%.s,%f%.f,%h%.h)do set %%~xa=0%%~na
- set ret=%.h:~-2%:%.f:~-2%:%.s:~-2%.%.w:~-2%
- endlocal&(if %2.==. (%ret%)else set %2=%ret%)&goto:eof
复制代码
作者: applba 时间: 2012-4-21 19:34
%XX%溢出了
作者: cjiabing 时间: 2012-4-21 20:03
- call edate "%dates:~0,10%" "%~2" xx
复制代码
找不到edate
复杂多!~
作者: 学无止境 时间: 2012-10-6 00:56
溢出!!!
作者: plp626 时间: 2012-10-6 12:19
回复 3# cjiabing - @echo off||倒计时;
- :: 备份自用 code by plp
-
- if "%1"==":timeout" (goto%1)else start/b %~fs0 :timeout "2015-1-1"
- cmd /k "prompt=-$g$s&echo 获取帮助请键入 help "
- exit
-
- :timeout
- set dates=%date%
- call:edate "%dates:~0,10%" "%~2" xx
- set/a xx-=1
- :lp
- call:time2i "%time%" i&call:i2time 8640000-i hfs
- title 现在距离 %~2 还有 %xx%天 零 %hfs% 秒
- goto:lp
-
- rem ------------------------- sub ----------------------------
- :time2i <time> <rt>
- setlocal&set t=%~1
- set/a w=1%t:~-2%,s=1%t:~-5,2%,f=1%t:~-8,2%,h=1%t:~-11,2%
- set/a w-=100,s-=100,f-=100,h-=100,i=h*3600+f*60+s,i=i*100+w
- endlocal&(if %2.==. (echo %i%)else set %2=%i%)&goto:eof
- :i2time <i> <hour> <minute> <second> <perseconde>
- setlocal&set/a t=%1
- set/a w=t%%100,t/=100,h=t/3600,t%%=3600,f=t/60,t%%=60,s=t
- for %%a in (%w%.w,%s%.s,%f%.f,%h%.h)do set %%~xa=0%%~na
- set ret=%.h:~-2%:%.f:~-2%:%.s:~-2%.%.w:~-2%
- endlocal&(if %2.==. (%ret%)else set %2=%ret%)&goto:eof
-
- :edate <"DATE1"> <"DATE2"> <RetVarName>
- setlocal
- set d1=%~1&set d2=%~2
- set d1=%d1:~0,10%&set d2=%d2:~0,10%
- set d1=%d1:-= %&set d2=%d2:-= %
- call:date2i %d1: 0= % i1
- call:date2i %d2: 0= % i2
- set/a c=i2-i1
- endlocal&(if %3.==. (echo %c%) else set %3=%c%)&goto:eof
-
- :date2i <year> <month> <day> <RetVarName>
- setlocal&set/a y=%1,m=%2,d=%3
- set/am+=9,m%%=12,y-=m/10,i=365*y+y/4-y/100+y/400+(m*153+2)/5+d-1
- endlocal&(if %4.==. (echo %i%)else set %4=%i%)&goto:eof
复制代码
作者: 111 时间: 2013-3-10 20:11
和- @echo off
- title 定时提醒器正在运行……
- :ma
- if '%1'=='%time:~0,2%:%time:~3,2%:%time:~6,2%' goto nlxx
- goto ma
- :nlxx
- title 闹铃响了!!!!!!
- :xiang
- nircmd beep 1000 200
- goto xiang
复制代码
一样
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |