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,706 of 68,980    |
|    Tom Del Rosso to Tom Del Rosso    |
|    Re: 24-hour format to 12-hour format usi    |
|    06 Dec 20 00:27:52    |
   
   From: fizzbintuesday@that-google-mail-domain.com   
      
   Tom Del Rosso wrote:   
   > Zaidy036 wrote:   
   >> On 12/5/2020 10:11 PM, Tom Del Rosso wrote:   
   >>> Zaidy036 wrote:   
   >>>> On 12/5/2020 8:50 PM, Tom Del Rosso wrote:   
   >>>>> 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   
   >>>>>   
   >>>> use Net Time https://ss64.com/nt/net-time.html   
   >>>>   
   >>>> FOR /F "tokens=7 delims= " %%n IN ('NET TIME \\PCname') DO SET   
   >>>> _TX=%%n   
   >>>   
   >>> That will take even longer to execute.   
   >>>   
   >>>   
   >>>   
   >> if a millisecond or two is that important have fun   
   >   
   > It's more than a millisecond to run an external program with the FOR   
   > command. It depends on a service running, and external commands are   
   > much more likely to have changes in syntax and also in output format   
   > between different OS versions.   
      
   Correction, it doesn't depend on the time service, but the other points   
   are valid.   
      
   --- 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