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

epochNanoseconds cannot exceed 10^8 days #1991

Closed
vbackeberg opened this issue Dec 26, 2021 · 2 comments
Closed

epochNanoseconds cannot exceed 10^8 days #1991

vbackeberg opened this issue Dec 26, 2021 · 2 comments
Labels

Comments

@vbackeberg
Copy link

I would like to cover dates up until a maximum value of 13 billion years, however "the range of allowed values for this type is the same as the old-style JavaScript Date, 100 million days".

Is there a reason to cap it at 10^8?

As temporal uses bigint, there is no boundary to the size of epochNanoseconds.

@ptomato
Copy link
Collaborator

ptomato commented Jan 8, 2022

This is a great question, glad you asked it!

There does need to be a cap — we've received a strong signal about this from browser implementors, who would otherwise be concerned about Temporal objects having unbounded storage requirements.

There are a few other concerns about not having a cap:

  • beyond a certain point you'd have to make the year field of PlainDate, PlainDateTime, PlainYearMonth, and ZonedDateTime a bigint as well, which would be cumbersome for most normal usage of Temporal.
  • the ISO 8601 interchange format requires defining a particular number of digits for the expanded year format (±YYYYYY-MM-DD) that consumers should be able to expect, you are not allowed to emit variable numbers of digits. So beyond a certain point we'd have to decline to serialize some objects and toString() would have to throw instead.

A while back, I wrote a cookbook example of how you might override certain Temporal methods in order to implement Temporal-like objects that supported an arbitrary range of years: https://tc39.es/proposal-temporal/docs/cookbook-expandedyears.html Maybe this approach would be good for your use case? (Although, I suspect you'd probably be better off using a dedicated 3rd-party library instead...)

You can find more discussion on this topic in #24 and #198. I hope that answers your question!

@vbackeberg
Copy link
Author

Thanks for your detailed answer!

@ptomato ptomato closed this as completed Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants