-
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
#1835: Support multiple date formats in Helper scripts #1837
Conversation
* added configuration for date parsing type * .gitattributes changed to hopefully better handle CRLF in native Windows files * LF -> CRLF in *.cmd and *.bat files
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.
LGTM (just read the code)
scripts/cmd/_run_enceladus.cmd
Outdated
| ::SET YYYY=%date:~10,4% | ||
| ::SET MM=%date:~4,2% | ||
| ::SET DD=%date:~7,2% | ||
| IF %DATE_PARSING_TYPE%==parser1 ( |
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.
In the most usual cases, this will probably work fine.
In general, the users can change the formats, so even the position-based parsing may not be sufficient (e.g. for the situation of (non)-padding with 0, short/long year, etc.
I suggest taking inspiration at https://ss64.com/nt/syntax-gettime.html | https://ss64.com/nt/syntax-gmt.html
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.
Nice. I will try to implement this in a free moment. This is no high priority. I pushed the change only because I needed a different parsing, so made it switchable, albeit not the smartest. 😉
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.
Yes, I agree that the current solution is probably good enough for the use case.
It just made sense to provide some information in the problematics in the broader sense, we may very well decide to leave it as-is, it would just be a bit more informed decision 😄
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.
Should be universal now 🤞
Also added configuration to prevent editor conversion from CRLF to LF
* automatic universal date & time parsing regardless of locale in Windows helper scripts * CRLF for *.cmd and *.bat files in editor
…s-in-helper-scripts
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.
- code reviewed
- pulled
- built
- run and disected
LGTM.
Personal remark: Oh, I so don't want to be writing stuff for CMD (Powershell seems to fill the blanks, at least. And the GOTO command 🙄 )
| 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 |
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.
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 comment
The 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 DD=%date:~8,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 "" ( |
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.
Funny I never learned PowerShell, and I find batch script surprisingly powerful. 👼 |
Based on this I dare to add // @dk1844 replying: yes, of course, I forgot to label it. |
…s-in-helper-scripts
|
Release notes used: |
…s-in-helper-scripts
|
Kudos, SonarCloud Quality Gate passed! |








I needed to implement the partial changes for my testing for other issues. So I thought to make it more general and include in code-base.
Release notes:
Configuration of the date parsing (locale dependent) to correctly name the log file.