
[已解決]批處理轉(zhuǎn)換秒數(shù)格式出錯求助看看哪里的問題最后由 hnfeng 于 -3-7 08:35想寫個“秒數(shù)”轉(zhuǎn)換為“hh:mm:ss” 格式的時間的函數(shù),但是運行時顯示“此時不應(yīng)有 else”,不知道哪里的問題,請高手看看:
nclick="copycode($('code0'));">復(fù)制代碼
- ::@echo off
- setlocal EnableDelayedExpansion&cd /d %~dp0&title %~nx0 &color 07
- call :Sec2Time 8 hhmmss
- echo 8 %hhmmss%
- pause
- call :Sec2Time 68 hhmmss
- echo 68 %hhmmss%
- pause
- call :Sec2Time 168 hhmmss
- echo 168 %hhmmss%
- pause
- call :Sec2Time 3668 hhmmss
- echo 3668 %hhmmss%
- pause
- call :Sec2Time 13668 hhmmss
- echo 13668 %hhmmss%
- pause
- exit /b
- ::==================================
- :Sec2Time
- setlocal ENABLEEXTENSIONS
- set hh=0
- set mm=0
- set ss=0
- if %1 LSS 60 (
- endlocal & set %2=!hh!:!mm!:%1
- ) else (
- if %1 LSS 3600 (
- set /a mm=%1 / 60
- set /a ss=$1 - (!mm! * 60)
- endlocal & set %2=!hh!:!mm!:!ss!
- ) else (
- set /a hh=%1 / 3600
- set /a mm=(%1 - (!hh! * 3600)) / 60
- set /a ss=%1 - !hh! * 3600 - !mm! * 60
- endlocal & set %2=!hh!:!mm!:!ss!
- )
- )
- goto :EOF

