Phil-Factor / PSYaml

A Powershell module to convert YAML documents to and from PowerShell objects
MIT License
91 stars 32 forks source link

Converts to Datetime (Unwanted) #27

Open midacts opened 5 years ago

midacts commented 5 years ago

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
shayki5 commented 4 years ago

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