From 6f4f7ee5508bdb7fa8f3c92dd4b7d97c0255e945 Mon Sep 17 00:00:00 2001 From: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:45:59 -0800 Subject: [PATCH 1/4] Prepare-Release.ps1: Make dateTime.ToString("MM/dd/yyyy") to work on exotic set-ups On my machine, I experimented with the registry, and the worst part is that I don't remember/know how to reset it back. The work items that script produces, do have datetimes for the upcoming releases in the `MM-dd-yyyy` format, and then I have to correct them by hand. `dateTime.ToString("MM/dd/yyyy")` does produce the date in the format of `MM-dd-yyyy` on my machine. This also happens if I write a corresponding .NET app. The fix that I am proposing makes it work on my specific setup and hopefully breaks no one else. I understand if you are hesitant to take it. Let me know, I'll see how I can restore my setting. But on the other hand, I don't think it makes anything worse, it only makes things more robust, so maybe take it? --- eng/common/scripts/Prepare-Release.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Prepare-Release.ps1 b/eng/common/scripts/Prepare-Release.ps1 index e3c18af350e0..d6964af4f4fc 100644 --- a/eng/common/scripts/Prepare-Release.ps1 +++ b/eng/common/scripts/Prepare-Release.ps1 @@ -109,7 +109,10 @@ else $ParsedReleaseDate = [datetime]$ReleaseDate } -$releaseDateString = $ParsedReleaseDate.ToString("MM/dd/yyyy") +# On some machines, where people modified date format via Windows Registry, +# "$ParsedReleaseDate.ToString("MM/dd/yyyy")" produces the date as "MM-dd-yyyy", which is probably a bug somewhere, +# yet if we concatenate the parts individually, everything works as expected. +$releaseDateString = $ParsedReleaseDate.ToString("MM") + "/" + $ParsedReleaseDate.ToString("dd") + "/" + $ParsedReleaseDate.ToString("yyyy") $month = $ParsedReleaseDate.ToString("MMMM") Write-Host "Assuming release is in $month with release date $releaseDateString" -ForegroundColor Green From 21dfe4df2062b459e51f14e53b1493b762e4b35f Mon Sep 17 00:00:00 2001 From: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:38:01 -0800 Subject: [PATCH 2/4] Use [CultureInfo]::InvarialtCulture Co-authored-by: Wes Haggard --- eng/common/scripts/Prepare-Release.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Prepare-Release.ps1 b/eng/common/scripts/Prepare-Release.ps1 index d6964af4f4fc..acfc88c1fe2a 100644 --- a/eng/common/scripts/Prepare-Release.ps1 +++ b/eng/common/scripts/Prepare-Release.ps1 @@ -112,7 +112,7 @@ else # On some machines, where people modified date format via Windows Registry, # "$ParsedReleaseDate.ToString("MM/dd/yyyy")" produces the date as "MM-dd-yyyy", which is probably a bug somewhere, # yet if we concatenate the parts individually, everything works as expected. -$releaseDateString = $ParsedReleaseDate.ToString("MM") + "/" + $ParsedReleaseDate.ToString("dd") + "/" + $ParsedReleaseDate.ToString("yyyy") +$releaseDateString = $ParsedReleaseDate.ToSTring("MM/dd/yyyy", [CultureInfo]::InvariantCulture) $month = $ParsedReleaseDate.ToString("MMMM") Write-Host "Assuming release is in $month with release date $releaseDateString" -ForegroundColor Green From 91be0d9ee25aeb49510a4c560f811f560c54f45f Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Fri, 2 Feb 2024 09:41:23 -0800 Subject: [PATCH 3/4] Update eng/common/scripts/Prepare-Release.ps1 --- eng/common/scripts/Prepare-Release.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/eng/common/scripts/Prepare-Release.ps1 b/eng/common/scripts/Prepare-Release.ps1 index acfc88c1fe2a..45d60e0d2419 100644 --- a/eng/common/scripts/Prepare-Release.ps1 +++ b/eng/common/scripts/Prepare-Release.ps1 @@ -109,9 +109,7 @@ else $ParsedReleaseDate = [datetime]$ReleaseDate } -# On some machines, where people modified date format via Windows Registry, -# "$ParsedReleaseDate.ToString("MM/dd/yyyy")" produces the date as "MM-dd-yyyy", which is probably a bug somewhere, -# yet if we concatenate the parts individually, everything works as expected. +# Use InvariantCulture so that the date format is consistent on all machines $releaseDateString = $ParsedReleaseDate.ToSTring("MM/dd/yyyy", [CultureInfo]::InvariantCulture) $month = $ParsedReleaseDate.ToString("MMMM") From e01b880eaac27b0761fa66b4f3eca22e33c1491e Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Fri, 2 Feb 2024 09:42:13 -0800 Subject: [PATCH 4/4] Update eng/common/scripts/Prepare-Release.ps1 --- eng/common/scripts/Prepare-Release.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Prepare-Release.ps1 b/eng/common/scripts/Prepare-Release.ps1 index 45d60e0d2419..269fd113fd69 100644 --- a/eng/common/scripts/Prepare-Release.ps1 +++ b/eng/common/scripts/Prepare-Release.ps1 @@ -110,7 +110,7 @@ else } # Use InvariantCulture so that the date format is consistent on all machines -$releaseDateString = $ParsedReleaseDate.ToSTring("MM/dd/yyyy", [CultureInfo]::InvariantCulture) +$releaseDateString = $ParsedReleaseDate.ToString("MM/dd/yyyy", [CultureInfo]::InvariantCulture) $month = $ParsedReleaseDate.ToString("MMMM") Write-Host "Assuming release is in $month with release date $releaseDateString" -ForegroundColor Green