Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,712 of 68,980    |
|    mokomoji to All    |
|    Re: 24-hour format to 12-hour format usi    |
|    24 Jan 21 09:34:22    |
      From: mokomoji@naver.com              2020년 12월 6일 일요일 오전 10시 50분 3초 UTC+9에 Tom Del       Rosso님이 작성한 내용:       > The last line is the thing I want to point out. It's a single equation        > that converts the hour from 24-hour format to 12-hour format. I'm sure        > this would run faster than an IF statement and more so if the IF was        > followed by a GOTO. In the past I have used IF because I hadn't thought        > of doing it all in arithmetic. But I don't see a way to avoid the IF        > that chooses am and pm.        >        > set tm=%time%        > set hr=%tm:~0,2%        > if %hr% LSS 12 (set AMPM=am) else (set AMPM=pm)        > set /a hr=hr%%12 + !hr*12 + !(hr-12)*12        >        > --                     @echo off       cd /d %~dp0       setlocal              for /l %%l in (1,1,23) do (       call set /a "z_t2=%%l/12"       call echo %%z_t2%%|find /i "1" 2>nul>nul&&set z_apm=PM||set z_apm=AM       call echo %%l--%%z_t2%%--%%z_apm%%       )              :end       endlocal       pause              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca