-
Notifications
You must be signed in to change notification settings - Fork 65
chore: Date time handling ADR #6397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marikaner
wants to merge
1
commit into
main
Choose a base branch
from
moment.js
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+70
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Date Handling | ||
|
|
||
| ## Status | ||
|
|
||
| proposed | ||
|
|
||
| ## Context | ||
|
|
||
| Currently the SAP Cloud SDK uses moment.js to handle dates. | ||
| As this library is no longer maintained, it is time to replace it with something different. | ||
|
|
||
| ### moment.js Motivation | ||
|
|
||
| Originally we decided to go with moment.js because the native JS Date object does not support timezone offsets. | ||
| It is not possible to retrieve the original timezone offset from a JS Date object. | ||
| Therefore (de-)serialization cannot be lossless with the plain JS Date. | ||
|
|
||
| ### Affected Code | ||
|
|
||
| This only affects the OData generator and the generated clients. | ||
|
|
||
| ### Requirements | ||
|
|
||
| - must have: lossless serialization round-trip | ||
| - should have: advanced date handling like comparison, formatting, timezone transformation, etc. | ||
| - nice to have: native JS | ||
|
|
||
| ## Decision | ||
|
|
||
| Use Temporal, see option A | ||
|
|
||
| ## Consequences | ||
|
|
||
| This cannot be achieved without breaking changes and will result in a major version update. | ||
|
|
||
| # Appendix | ||
|
|
||
| ## Option A - Temporal.js | ||
|
|
||
| Good news! | ||
| Temporal has become a stage 4 proposal as of March 11th ([see the 9 year journey](https://bloomberg.github.io/js-blog/post/temporal/)). | ||
| This is the obvious candidate, given that Temporal is now officially becoming part of ES2026 and Node.js v26 and it is [available through TS 6](https://devblogs.microsoft.com/typescript/announcing-typescript-6-0-rc/#new-types-for-temporal) already. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps also link https://www.github.com/tc39/ecma262/pull/3759 |
||
|
|
||
| For a quick win, we can already recommend usage of the temporal de-serializers as of today. | ||
|
|
||
| - fulfills all requirements from above | ||
| - higher maintenance effort | ||
|
|
||
| ## Option B - Plain String | ||
|
|
||
| We discussed this option many times: Instead of deserializing the data in the Cloud SDK, leave it to users instead. | ||
| If we do this for dates, for consistency we should also do this for big numbers (bignumber.js). | ||
|
|
||
| - less convenient for users | ||
| - lower maintenance effort | ||
| - potentially more flexibility for users as they get the plain data as is | ||
|
|
||
| ## Option C - Hybrid | ||
|
|
||
| Do option B by default, but provide a middleware that allows users to deserialize to Temporal Dates as well. | ||
|
|
||
| - highest level of flexibility | ||
| - implementation might be very complex | ||
|
|
||
| ## Notes | ||
|
|
||
| For options A and B I suggest to remove the whole (de-)serializers concept ([ADR 15](./outdated/0015-date-time-handling.md)). | ||
| Although the flexibility is a plus, it makes everything harder to consume and maintain. | ||
| Also, there is little proof, that this is used by anyone, given that I am not aware of any user issues with regards to this and the [download numbers of the temporal de-serializers package](https://www.npmjs.com/package/@sap-cloud-sdk/temporal-de-serializers). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| ## Status | ||
|
|
||
| decided | ||
| superseded | ||
|
|
||
| ## Context | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this mean using/recommending a polyfill until Node.js v26 is released, or is this a plan for postponement?