You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get-IshBaselineItem parses incoming ModifiedOn and CreatedOn values using CurrentCulture instead resulting in Month Day swapping for some Regional Settings
#157
Closed
3 tasks done
ddemeyer opened this issue
Jul 6, 2023
· 0 comments
Problem...
Similar issue to #137 where all <ishfield> based values were corrected, however <object> based values, typical for Baseline Items retrieval was missed. See also SRQ-22720.
$p=Get-IshPublicationOutput-LogicalId GUID-1BC6D615-95BD-420E-B654-7E299EE84C78 |Out-GridView-PassThru # selecting one row$bi=Get-IshBaselineItem-Id $p.fishbaseline_version_element$bi[0].ModifiedOn
Sunday, August 6,20235:23:45 PM
$bi[0].ModifiedOnAsSortableDateTime
2023-08-06T17:23:45# which is in the future at the time of writing
Workaround...
Use ([System.Globalization.CultureInfo]::CurrentCulture).DateTimeFormat.ShortDatePattern = "dd/MM/yyyy" in front of your PowerShell code. This operation will only set the ShortDatePattern for this PowerShell session, any new PowerShell session gets the system value again. It will make sure that the ISHRemote uses this CurrentCulture and parses DateTime objects correctly.
Suggested fix...
Add GetIshBaselineItem.Tests.ps1 to at least test that the Set entry comes back from the server in the same way. Note that this test will always pass from day 13 to day 31 of the month because of the parsing fall back, but it should catch issues on day 1 to 12 as those could be parsed as months.
Extract DateTime parsing from \HelperClasses\NameHelper.cs::GetPSNoteProperty into separate method HelperClasses\NameHelper.cs::TryParseDateTimeExact to reuse in GetPSNoteProperty method
Add new TryParseDateTimeExact method in \Objects\Public\IshBaselineItem.cs::IshBaselineItem to no longer use implicit CurrentCulture for parsing CreatedOn and ModifiedOn properties.
The text was updated successfully, but these errors were encountered:
…ues using CurrentCulture instead resulting in Month Day swapping for some Regional Settings ... Added a basic test before the actual code change, again Regional Options issues on the build server
…ues using CurrentCulture instead resulting in Month Day swapping for some Regional Settings ... Again Regional Options issues on the build server plus actual fix for BaselineItem datetimes parsing
…ues using CurrentCulture instead resulting in Month Day swapping for some Regional Settings ... Again Regional Options issues on the build server plus actual fix for BaselineItem datetimes parsing
Problem...
Similar issue to #137 where all
<ishfield>
based values were corrected, however<object>
based values, typical for Baseline Items retrieval was missed. See also SRQ-22720.Workaround...
Use
([System.Globalization.CultureInfo]::CurrentCulture).DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"
in front of your PowerShell code. This operation will only set the ShortDatePattern for this PowerShell session, any new PowerShell session gets the system value again. It will make sure that the ISHRemote uses this CurrentCulture and parses DateTime objects correctly.Suggested fix...
GetIshBaselineItem.Tests.ps1
to at least test that the Set entry comes back from the server in the same way. Note that this test will always pass from day 13 to day 31 of the month because of the parsing fall back, but it should catch issues on day 1 to 12 as those could be parsed as months.\HelperClasses\NameHelper.cs::GetPSNoteProperty
into separate methodHelperClasses\NameHelper.cs::TryParseDateTimeExact
to reuse inGetPSNoteProperty
methodTryParseDateTimeExact
method in\Objects\Public\IshBaselineItem.cs::IshBaselineItem
to no longer use implicit CurrentCulture for parsing CreatedOn and ModifiedOn properties.The text was updated successfully, but these errors were encountered: