PSYaml icon indicating copy to clipboard operation
PSYaml copied to clipboard

Converts to Datetime (Unwanted)

Open midacts opened this issue 6 years ago • 1 comments

ConvertFrom-Yaml is converting strings to datetime.

I understand that '12/31/1999' looks like a date format, but i am passing it in as a string because i want the value to actually be '12/31/1999'

# Test YAML
$y = @"
test:
  tag: 12/31/1999
@"

# Converts to PS object
$PSObj = $y | ConvertToYaml

# Outputs the results
C:\> $PSObj['test']

Name                  Value
----                      -----
tag                      12/31/1999 12:00:00 AM

# Shows the type
C:\> $PSObj['test'].tag.gettype()

IsPublic IsSerial Name
-------- -------- ----
True     True     DateTime

midacts avatar Nov 01 '19 17:11 midacts

See this issue: https://github.com/Phil-Factor/PSYaml/issues/20 and the workaround there.

shayki5 avatar Jun 11 '20 10:06 shayki5