- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15
 
#1835: Support multiple date formats in Helper scripts #1837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1987301
              31cbffd
              55e3693
              986edfe
              e51239b
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -602,6 +602,7 @@ IF "%ASYNCHRONOUS_MODE%"=="true" ( | |
| GOTO :eof | ||
| 
     | 
||
| :client_run | ||
| 
     | 
||
| CALL :temp_log_file TMP_PATH_NAME | ||
| 
     | 
||
| :: Initializing Kerberos ticket | ||
| 
          
            
          
           | 
    @@ -658,17 +659,20 @@ EXIT /B 0 | |
| EXIT /B 0 | ||
| 
     | 
||
| :temp_log_file | ||
| SET yyyy=%date:~-4% | ||
| SET MM=%date:~3,2% | ||
| SET DD=%date:~0,2% | ||
| ::alternate date parsing | ||
| ::SET YYYY=%date:~10,4% | ||
| ::SET MM=%date:~4,2% | ||
| ::SET DD=%date:~7,2% | ||
| SET HH=%time:~0,2% | ||
| IF %HH% lss 10 (SET HH=0%time:~1,1%) | ||
| SET MI=%time:~3,2% | ||
| SET SS=%time:~6,2% | ||
| ::Date&Time parsing | ||
| FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO ( | ||
| if "%%B" NEQ "" ( | ||
| SET /A FDATE=%%F*10000+%%D*100+%%A | ||
| :: prefixing 1000000 to ensure the hours is two digit (starting with 0 before 10) | ||
| SET /A FTIME=1000000+%%B*10000+%%C*100+%%E | ||
| 
         
      Comment on lines
    
      +665
     to 
      +667
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very interesting approach, but why not. I would have naturally attempted to created a number-padding method, but this works well, too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found it the easiest. Batch scripts are designed to manipulate strings, as I see it 😉  | 
||
| ) | ||
| ) | ||
| SET YYYY=%FDATE:~0,4% | ||
| SET MM=%FDATE:~4,2% | ||
| SET DD=%FDATE:~6,2% | ||
| SET HH=%FTIME:~1,2% | ||
| SET MI=%FTIME:~3,2% | ||
| SET SS=%FTIME:~5,2% | ||
| SET DATETIME=%YYYY%_%MM%_%DD%-%HH%_%MI%_%SS% | ||
| CALL :last_part NAME,.,%CLASS% | ||
| :loop_gtlf | ||
| 
          
            
          
           | 
    ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, naturally, I would have looked for cmd alternative for shell
myCommand | head -n2 | tail -n1, but this seems to be simply available only in powershell 🙄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I admit, I found this on the Internet, not my invention at all.