sdk-go icon indicating copy to clipboard operation
sdk-go copied to clipboard

Properly marshal event time to RFC-3339 format

Open Cali0707 opened this issue 1 year ago • 4 comments

In event_marshal.go, time.String() is currently used to marshal the time to a string: https://github.com/cloudevents/sdk-go/blob/ba92a5c9a1e2508d855930049999ccd75636f0cb/v2/event/event_marshal.go#L76-L79

However, in the go time.Time documentation, it says about the method time.Time.String():

The returned string is meant for debugging; for a stable serialized representation, use t.MarshalText, t.MarshalBinary, or t.Format with an explicit format string.

In the Spec, it is required that the time is serialized to RFC-3339, so we should be using time.Time.MarshalText instead

Cali0707 avatar Nov 23 '23 19:11 Cali0707

Or time.Format() with RFC3339 - wanna submit a PR?

duglin avatar Jan 31 '24 15:01 duglin

Happy to open a PR, but I know @MaryamTaj has been wanting to make some contributions so I'll see if she is interested in this one first :)

Cali0707 avatar Jan 31 '24 19:01 Cali0707

@duglin I would love to work on this!

MaryamTaj avatar Feb 01 '24 02:02 MaryamTaj

Commented in the PR to discuss whether this must be considered a breaking change.

embano1 avatar Feb 18 '24 06:02 embano1