Time difference
Posted: 17 Feb 2015 09:28
Hi all!
I found this excelent code at SO by Aacini (http://stackoverflow.com/a/9935540):
I modified it slightly to fit my needs (removed hundrendths of a second becuase I don't need that) and then I added a 'Time left' info to my Progress bar (viewtopic.php?p=33603#p33603) (image hosting site is down at the moment).
(this image is uploaded to a different server from the same company)
Looks nice.
Another question:
What would be the best solution if I start the process before midnight and when time changes from 23:xx:xx to 00:xx:00 to have a correct time difference? Maybe adding 24 to hours? Or maybe adding dates to start time and end time?
Saso
I found this excelent code at SO by Aacini (http://stackoverflow.com/a/9935540):
Code: Select all
@echo off
rem Get start time:
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
rem Any process here...
rem Get end time:
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
rem Get elapsed time:
set /A elapsed=end-start
rem Show elapsed time:
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
if %mm% lss 10 set mm=0%mm%
if %ss% lss 10 set ss=0%ss%
if %cc% lss 10 set cc=0%cc%
echo %hh%:%mm%:%ss%,%cc%
I modified it slightly to fit my needs (removed hundrendths of a second becuase I don't need that) and then I added a 'Time left' info to my Progress bar (viewtopic.php?p=33603#p33603) (image hosting site is down at the moment).
(this image is uploaded to a different server from the same company)
Looks nice.
Another question:
What would be the best solution if I start the process before midnight and when time changes from 23:xx:xx to 00:xx:00 to have a correct time difference? Maybe adding 24 to hours? Or maybe adding dates to start time and end time?
Saso