Skip to content
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

Experiment with Temporal API #105

Draft
wants to merge 50 commits into
base: main
Choose a base branch
from
Draft

Experiment with Temporal API #105

wants to merge 50 commits into from

Conversation

meduzen
Copy link
Owner

@meduzen meduzen commented Oct 14, 2023

Currently the code is a 1:1 match with the last version of datetime-attribute in terms of feature.

List of things:

  • Use the Temporal API everywhere it’s possible to be familiar with its ergonomics.
  • Update the test cases to be on par with recent updates on main.
  • How to enhance the API of datetime-attribute with Temporal specifics? For example: on top of accepting Date objects, most functions could also accept some of the many Temporal objects.
  • Currently, this PR makes use of the Temporal API everywhere it can so that I can experiment a bit with its big set of features. But it should be changed to only make use of it everywhere it should, and keep the regular Date API. This should be done after having experimented/played with additional features (see previous point).
  • Generate types (only done for the non-Temporal implementation for now)
  • Think about new test cases coming with the specificities of Temporal API
  • Document
  • How to release this experimental version?
    • Should @js-temporal/polyfill stays as peerDependencies? If yes, it allows size-limit to report the “real” size because the polyfill will not end in the final bundle. If no, it should be moved to devDependencies so it doesn’t required to be installed for the regular datetime-attribute, which doesn’t need the polyfill. Complicated.
  • Study performance… which won't happen as long as no browser implements it aside from Safari as experimental, thou it could be tried in a Node environment (Deno has started with it).

@meduzen meduzen added the enhancement New feature or request label Oct 14, 2023
@meduzen meduzen self-assigned this Oct 14, 2023
@what-the-diff
Copy link

what-the-diff bot commented Oct 14, 2023

PR Summary

  • Addition of Duration Attribute
    The addition of the src/temporal/duration.js file brings the ability to create a duration attribute for time tags, allowing more precise control over timing features.

  • Export of Duration Function
    The new src/temporal/index.js file allows the previously implemented duration function to be exported for wider accessibility and use within the codebase.

  • Introduction of Date Calculations Functions
    Further enhancing our temporal control, the src/temporal/utils/date.js file contains functions for calculating differences between two given dates in days and determining the week number of a specific date.

  • Conversion of Date Object Function
    A new utility function dateToPlainDate is introduced in src/temporal/utils/temporal.js file to make the conversion of a JavaScript Date object to a Temporal.PlainDate object smoother.

  • Path Addition in package.json
    The package.json file has been updated with a new path src/temporal/index.js utilizing brotli compression for optimized use.

  • New Dependency Addition
    For further enhancement and functionality, @js-temporal/polyfill dependency has been added with a version of ^0.4.4 in the pnpm-lock.yaml file.

  • Resolutions and Dependencies update
    The pnpm-lock.yaml file has also been updated with new resolutions and dependencies for [email protected] and [email protected], ensuring all elements are up-to-date and secure.

Please note that these changes improve efficiency, calculation capacity and speed up some processes, hence enhance the user's experience.

@github-actions
Copy link

github-actions bot commented Oct 14, 2023

size-limit report 📦

Path Size
datetime 601 B (0%)
utc 605 B (0%)
datetimeTz 874 B (0%)
duration 244 B (0%)
tzOffset 313 B (0%)
setTimeSeparator 125 B (0%)
setTzConfig 181 B (0%)
setTzInRealWorldRange 196 B (0%)
setTzSeparator 194 B (0%)
daysBetween 68 B (0%)
weekNumber 144 B (0%)
DateTime 661 B (0%)
All modules (import *) 1.3 KB (0%)
datetime (Temporal) 502 B (+100% 🔺)
utc (Temporal) 496 B (+100% 🔺)
datetimeTz (Temporal) 825 B (+100% 🔺)
duration (Temporal) 287 B (+100% 🔺)
tzOffset (Temporal) 360 B (+100% 🔺)
setTimeSeparator (Temporal) 125 B (+100% 🔺)
setTzConfig (Temporal) 181 B (+100% 🔺)
setTzInRealWorldRange (Temporal) 196 B (+100% 🔺)
setTzSeparator (Temporal) 194 B (+100% 🔺)
daysBetween (Temporal) 61 B (+100% 🔺)
weekNumber (Temporal) 49 B (+100% 🔺)
DateTime (Temporal) 591 B (+100% 🔺)
All modules (import *, Temporal) 1.54 KB (+100% 🔺)

@meduzen
Copy link
Owner Author

meduzen commented Nov 25, 2023

Quoting to see how it evolves. This is by using the Temporal API everywhere it’s possible:

size-limit report 📦

Path Size
datetime 601 B (0%)
utc 605 B (0%)
datetimeTz 843 B (0%)
duration 245 B (0%)
tzOffset 286 B (0%)
setTimeSeparator 125 B (0%)
setTzSeparator 116 B (0%)
daysBetween 68 B (0%)
weekNumber 144 B (0%)
DateTime 659 B (0%)
All modules (import *) 1.21 KB (0%)
datetime (Temporal) 481 B (+100% 🔺)
utc (Temporal) 480 B (+100% 🔺)
datetimeTz (Temporal) 771 B (+100% 🔺)
duration (Temporal) 287 B (+100% 🔺)
tzOffset (Temporal) 319 B (+100% 🔺)
setTimeSeparator (Temporal) 125 B (+100% 🔺)
setTzSeparator (Temporal) 116 B (+100% 🔺)
daysBetween (Temporal) 62 B (+100% 🔺)
weekNumber (Temporal) 49 B (+100% 🔺)
DateTime (Temporal) 577 B (+100% 🔺)
All modules (import *, Temporal) 1.42 KB (+100% 🔺)

@meduzen meduzen added the feat: temporal Related to the Temporal API label Apr 19, 2024
@meduzen
Copy link
Owner Author

meduzen commented Oct 9, 2024

Work can be resumed at any time, but best to wait for the polyfills to catch-up on the spec changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat: temporal Related to the Temporal API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant