Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

src(event)!: make the event's time property only a string #330

Merged
merged 1 commit into from
Sep 1, 2020

Conversation

lance
Copy link
Member

@lance lance commented Aug 28, 2020

Proposed Changes

  • Change CloudEvent's time property to be only a string
  • Remove all special handling of the time property in getters/setters
  • Ensure that event.time always produces the value provided in the constructor
  • Add validation logic so that new Date().toString() works with event attribute validation
  • Improve the DateParser which processes an incoming binary event Message's ce-time header and time property for a structured event Message.

Description

Previously, the event's time property could be either a string or a date.
this commit modifies that to ensure that the object can only be created with
a timestamp in string format. As long as the string is a valid date, that
can be parsed by new Date(Date.parse(str)) then whenever the event is
serialized as JSON, the time attribute will be formatted as per RFC 3339.

BREAKING CHANGE

Signed-off-by: Lance Ball lball@redhat.com

Previously, the event's `time` property could be either a string or a date.
this commit modifies that to ensure that the object can only be created with
a timestamp in string format. As long as the string is a valid date, that
can be parsed by `new Date(Date.parse(str))` then whenever the event is
serialized as JSON, the `time` attribute will be formatted as per RFC 3339.

Fixes: cloudevents#326

Signed-off-by: Lance Ball <lball@redhat.com>
@lance lance added type/enhancement New feature or request module/lib Related to the main source code version/4.x Issues related to the 4.0 release of this library labels Aug 28, 2020
@lance lance requested a review from a team August 28, 2020 19:15
@lance lance self-assigned this Aug 28, 2020
Copy link
Member

@grant grant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, cool!

@lance lance merged commit 6cd310c into cloudevents:main Sep 1, 2020
@lance lance deleted the 326-make-date-string-only branch September 1, 2020 14:10
@github-actions github-actions bot mentioned this pull request Sep 17, 2020
@github-actions github-actions bot mentioned this pull request Oct 13, 2020
@lholmquist lholmquist mentioned this pull request Dec 11, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
module/lib Related to the main source code type/enhancement New feature or request version/4.x Issues related to the 4.0 release of this library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: time attribute is always a string, yet is type casted to string | Date
2 participants