To help you better we need some information from you.
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product, version and build: PowerShell Studio 2017, 5.4.144
32 or 64 bit version of product: 64-bit
Operating system:
32 or 64 bit OS: 64-bit
*** Please add details and screenshots as needed below. ***
I have a line of code that the 'Format Script' breaks the formatting of a string. The following code will demonstrate the :
$TempDate = (New-Object System.DateTimeOffset((get-date)))
("$($TempDate.LocalDateTime.ToString('yyyy-MM-dd HH:mm:ss.fffffff')) $($TempDate.OffSet.Hours):$({00} -f $TempDate.OffSet.Minutes)" -replace " 0:00$", " -0:00")
Get's reformatted to:
$TempDate = (New-Object System.DateTimeOffset((get-date)))
("$($TempDate.LocalDateTime.ToString('yyyy-MM-dd HH:mm:ss.fffffff')) $($TempDate.OffSet.Hours):$({
00
} -f $TempDate.OffSet.Minutes)" -replace " 0:00$", " -0:00")
which breaks the return value.
DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
Format script damaging string format
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Format script damaging string format
I wasn't able to replicate the issue in PS version 144. I copy/paste the code then reformat the script and didn't break code at the brackets {}. Although the code provided has some errors.
Seems the one-liner don't need to use the replace and the results could be simpler.
Try the following to see if agree with it. Here are some variations:
$($TempDate.LocalDateTime.ToString('yyyy-MM-dd HH:mm:ss.00'))
$($TempDate.LocalDateTime.ToString('yyyy-MM-dd HH:mm'))
$($TempDate.LocalDateTime.ToString('yyyy-MM-dd HH:00'))
Seems the one-liner don't need to use the replace and the results could be simpler.
Try the following to see if agree with it. Here are some variations:
$($TempDate.LocalDateTime.ToString('yyyy-MM-dd HH:mm:ss.00'))
$($TempDate.LocalDateTime.ToString('yyyy-MM-dd HH:mm'))
$($TempDate.LocalDateTime.ToString('yyyy-MM-dd HH:00'))
- jdainsworth
- Posts: 25
- Last visit: Thu Dec 14, 2023 9:10 am
Re: Format script damaging string format
Your sample code does not provide the output in ISO 8601 format (YYYY-MM-DDThh:mm:ss[.nnnnnnn][{+|-}hh:mm]).
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Format script damaging string format
Ah! Understood.
Sometime ago, I work in a Biztalk project were the XML needed to provide an ISO 8601 date format but coming from a SQL table date field.
Maybe the following line might be (sort of) starting point then break it in pieces:
$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fffffffzzz'))
Still I wasn't able to replicate the issue you were experience. I remember seem it in older version of PowerShell Studio but not on the current one.
Sometime ago, I work in a Biztalk project were the XML needed to provide an ISO 8601 date format but coming from a SQL table date field.
Maybe the following line might be (sort of) starting point then break it in pieces:
$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fffffffzzz'))
Still I wasn't able to replicate the issue you were experience. I remember seem it in older version of PowerShell Studio but not on the current one.
- jdainsworth
- Posts: 25
- Last visit: Thu Dec 14, 2023 9:10 am
Re: Format script damaging string format
It would be nice to address the formatting issue, because it does seem to be an interpreter issue. Below are my formatting options.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Format script damaging string format
Thanks for providing the screen image. Of course, I got different setting:
if ($value)
{
Out-Default 'True'
}
else
{
Out-Default 'False'
}
Let me change it and get back to you.
if ($value)
{
Out-Default 'True'
}
else
{
Out-Default 'False'
}
Let me change it and get back to you.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Format script damaging string format
Ok! I was able to replicate the issue.
Please try the following settings "Checked" on:
x Place open brace on new line
x Place statement keyword on a new line
x Insert new line after Parameter attribute
x Align hashtable equal signs
x Leave block on the same line (I'm sure is is the one)
x convert curly quotes to straight quotes
Let me know if it work this time.
Please try the following settings "Checked" on:
x Place open brace on new line
x Place statement keyword on a new line
x Insert new line after Parameter attribute
x Align hashtable equal signs
x Leave block on the same line (I'm sure is is the one)
x convert curly quotes to straight quotes
Let me know if it work this time.