Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Relationship between BigInt and Date #136

Closed
joyeecheung opened this issue Mar 27, 2018 · 6 comments
Closed

Relationship between BigInt and Date #136

joyeecheung opened this issue Mar 27, 2018 · 6 comments

Comments

@joyeecheung
Copy link

joyeecheung commented Mar 27, 2018

I was working on a prototype of BigInt support for fs.Stat in Node.js and I noticed that there are no way to construct a Date out of ms in BigInt. In a conversation with @littledan I learned that it's because Date is Number-based, a better solution for date time with BigInt support would be the Temporal proposal. It would be good if there is explanation in the README about this.

@ljharb
Copy link
Member

ljharb commented Mar 27, 2018

Is there any reason not to allow a BigInt as well as a Number in Date?

@littledan
Copy link
Member

Date's data model is already fundamentally broken. I don't see the point of complicating it with BigInt; precision is sort of the least of Date's problems. I like @maggiepint's approach of a new set of classes to resolve this issue instead.

@ljharb
Copy link
Member

ljharb commented Mar 27, 2018

I certainly want the Temporal proposal; but I'm not sure making BigInt unergonomic when combined with existing builtins is appropriate.

@littledan
Copy link
Member

The BigInt design is predicated on it being OK to be unergonomic in existing libraries and interfaces. We decided it's better to ask programmers to explicitly request the precision loss with a call to Number(). If you want to start improving Date's data model, that sounds like a big project that you could champion.

@apaprocki
Copy link
Contributor

There is a starting-point polyfill for Temporal now, and it uses BigInt. If you'd like to take a peek, please submit feedback there

https://github.com/tc39/proposal-temporal/pull/57/files#diff-4c66be3ac0c3f5b83e963105c61aa60bR39

@littledan
Copy link
Member

OK, we'll continue pursuing this effort in the context of the temporal proposal. Thanks everyone! Closing this issue to discuss over there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants