Last active
July 13, 2018 12:50
-
-
Save memset0/c76902d841f35be8a75d32a3f5de9523 to your computer and use it in GitHub Desktop.
获取两次操作中间相隔了多少时间并做一些简单的转换
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:loop | |
set t_before=1%time:~3,2%%time:~6,2%%time:~9,2% | |
pause | |
set t_after=1%time:~3,2%%time:~6,2%%time:~9,2% | |
if %t_before% gtr %t_after% set /a t_after=%t_after%+216000 | |
set /a t_time=%t_after%-%t_before% | |
set /a t_min=%t_time%/3600 | |
set /a t_sec=(%t_time%-%t_min%*3600)/60 | |
set /a t_mis=%t_time%-%t_min%*3600-%t_sec%*60 | |
if %t_mis% lss 10 set t_mis=0%t_mis% | |
if %t_min% gtr 0 ( | |
if %t_sec% lss 10 ( | |
set t_sec=0%t_sec% | |
) | |
echo %t_min%:%t_sec%.%t_mis% | |
) else ( | |
echo %t_sec%.%t_mis% | |
) | |
goto loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:loop | |
set t_before=1%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2% | |
pause | |
set t_after=1%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2% | |
set /a t_time=%t_after%-%t_before% | |
set /a t_sec=%t_time%/60 | |
set /a t_mis=%t_time%-%t_sec%*60 | |
if %t_mis% lss 10 set t_mis=0%t_mis% | |
echo %t_sec%.%t_mis% | |
goto loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment