Skip to content
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

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
Milestone

Comments

@ddemeyer
Copy link
Contributor

ddemeyer commented Jul 6, 2023

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, 2023 5: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.
@ddemeyer ddemeyer added this to the v7.1 milestone Jul 6, 2023
ddemeyer pushed a commit that referenced this issue Jan 25, 2024
…ues using CurrentCulture instead resulting in Month Day swapping for some Regional Settings ... Added a basic test before the actual code change
ddemeyer pushed a commit that referenced this issue Jan 26, 2024
…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
ddemeyer pushed a commit that referenced this issue Jan 26, 2024
…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
ddemeyer pushed a commit that referenced this issue Jan 26, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant