go-yaml / yaml

YAML support for the Go language.
Other
6.84k stars 1.04k forks source link

Invalid date-time format during marshalling returns unquoted value. Expecting quoted value. #1009

Open Akashr7n opened 10 months ago

Akashr7n commented 10 months ago

(Below is example without 'Z') Actual: date: 2020-04-15T00:00:00

Expecting: date: '2020-04-15T00:00:00'

Akashr7n commented 9 months ago

@rogpeppe / @niemeyer Could you please help look into this. Am I expecting anything wrong?

romshark commented 4 months ago

time.Time implements encoding.TextUnmarshaler and encoding.TextMarshaler as unquoted RFC3339 (see source): https://go.dev/play/p/91Czuy75Xwl. Why would you expect it to be quoted?

Marshaling/unmarshaling Works fine with v3: https://go.dev/play/p/9dGIFChLTDs. Also, 2020-04-15T00:00:00 is not a valid RFC3339 timestamp https://go.dev/play/p/RtIEqzhnNRQ.