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

Unexpected yaml date conversion #301

Open
Ash258 opened this issue Feb 20, 2023 · 0 comments
Open

Unexpected yaml date conversion #301

Ash258 opened this issue Feb 20, 2023 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Ash258
Copy link
Owner

Ash258 commented Feb 20, 2023

  • Branch: all
  • Powershell Version: all

# From the YAML spec: http://yaml.org/type/timestamp.html
$regex = @'
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] # (ymd)
|[0-9][0-9][0-9][0-9] # (year)
-[0-9][0-9]? # (month)
-[0-9][0-9]? # (day)
([Tt]|[ \t]+)[0-9][0-9]? # (hour)
:[0-9][0-9] # (minute)
:[0-9][0-9] # (second)
(\.[0-9]*)? # (fraction)
(([ \t]*)Z|[-+][0-9][0-9]?(:[0-9][0-9])?)? # (time zone)
'@
if([Text.RegularExpressions.Regex]::IsMatch($Node.Value, $regex, [Text.RegularExpressions.RegexOptions]::IgnorePatternWhitespace) ) {
[DateTime]$datetime = [DateTime]::MinValue
if( ([DateTime]::TryParse($Node.Value,[ref]$datetime)) ) {
return $datetime
}
}

image
https://yaml.org/type/timestamp.html

@Ash258 Ash258 added the bug Something isn't working label Feb 20, 2023
@Ash258 Ash258 added this to the Backlog milestone Feb 20, 2023
@Ash258 Ash258 self-assigned this Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant