-
Notifications
You must be signed in to change notification settings - Fork 199
Fix DateTime parsing fails on non-US locale runners #2047
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7546918
Initial plan
Copilot a034eb2
Fix DateTime locale-agnostic serialization using ISO 8601 format
Copilot dc6fa1f
Apply suggestion from @mazhelez
mazhelez 3e1c750
Add release notes entry for DateTime locale fix (Issue #2045)
Copilot 2833097
Ensure datetime is converted to UTC before calculating duration
Copilot 44c6785
Merge branch 'main' into copilot/fix-datetime-parsing-bug
mazhelez c35f62d
Merge branch 'main' into copilot/fix-datetime-parsing-bug
mazhelez 5702191
Move Issue 2045 release notes to unreleased section above v8.1
Copilot ad05b6b
Merge branch 'main' into copilot/fix-datetime-parsing-bug
mazhelez 5952fd6
Merge branch 'main' into copilot/fix-datetime-parsing-bug - resolve R…
Copilot dbce971
Merge branch 'main' into copilot/fix-datetime-parsing-bug - resolve c…
Copilot 0d64c05
Merge branch 'main' into copilot/fix-datetime-parsing-bug
mazhelez 049409f
Merge branch 'main' into copilot/fix-datetime-parsing-bug
mazhelez 6b92269
Refactor datetime parsing into testable function and add locale testing
Copilot efc102a
Merge branch 'main' into copilot/fix-datetime-parsing-bug
mazhelez b90d721
Use ConvertToUtcDateTime function from WorkflowPostProcess.ps1 instea…
Copilot bee17fb
Clean up whitespace in DateTime serialization test for consistency
mazhelez 7594d99
Add GetWorkflowDuration function and update tests for locale handling
mazhelez 62d8f04
Update Actions/.Modules/WorkflowPostProcessHelper.psm1
mazhelez c172060
Merge branch 'main' into copilot/fix-datetime-parsing-bug
mazhelez 60d4130
Merge branch 'main' into copilot/fix-datetime-parsing-bug
aholstrup1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Helper functions for WorkflowPostProcess action | ||
|
|
||
| .DESCRIPTION | ||
| Contains utility functions used by the WorkflowPostProcess action and its tests | ||
| #> | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Calculate the duration of a workflow from a start time | ||
|
|
||
| .DESCRIPTION | ||
| Calculates the duration in seconds from the provided start time to the current UTC time. | ||
| Handles both DateTime objects and string representations in any date format that can be parsed by the invariant culture (e.g., ISO 8601 or other culture-independent formats). | ||
|
|
||
| .PARAMETER StartTime | ||
| The workflow start time as either a DateTime object or a string in any date format that can be parsed by the invariant culture (such as ISO 8601 or other culture-independent formats) | ||
|
|
||
| .PARAMETER EndTime | ||
| (Optional) The end time as a DateTime object. Defaults to the current UTC time. | ||
|
|
||
| .EXAMPLE | ||
| $duration = GetWorkflowDuration -StartTime "2025-12-12T10:00:00.0000000Z" -EndTime ([DateTime]::UtcNow) | ||
|
|
||
| .EXAMPLE | ||
| $duration = GetWorkflowDuration -StartTime ([DateTime]::UtcNow) | ||
| #> | ||
| function GetWorkflowDuration { | ||
| Param( | ||
| [Parameter(Mandatory = $true)] | ||
| $StartTime, | ||
| [Parameter(Mandatory = $false)] | ||
| $EndTime = [DateTime]::UtcNow | ||
| ) | ||
|
|
||
| if ($StartTime -is [DateTime]) { | ||
| $workflowStartTime = $StartTime.ToUniversalTime() | ||
| } else { | ||
| $workflowStartTime = [DateTime]::Parse($StartTime, [System.Globalization.CultureInfo]::InvariantCulture, [System.Globalization.DateTimeStyles]::AdjustToUniversal) | ||
| } | ||
|
|
||
| $workflowDuration = $EndTime.ToUniversalTime().Subtract($workflowStartTime).TotalSeconds | ||
| return $workflowDuration | ||
| } | ||
|
|
||
| Export-ModuleMember -Function GetWorkflowDuration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.