I understand that an ECMAScript date just stores a time value in epoch time (the number of milliseconds since midnight on 1 January 1970 UTC).
But looking over the algorithm for the Date() constructor, I only see where the argument values are converted to milliseconds; I don't see where the millisecond value is converted to epoch time. Where does that step happen?
CodePudding user response:
The Date constructor algorithm calls MakeDay, which returns the number of days since epoch for the argument values. MakeDate then does convert that number of days to the number milliseconds by simple multiplication.
MakeDay contains the following step:
- Find a finite time value
tsuch that YearFromTime(t) isymand MonthFromTime(t) ismnand DateFromTime(t) is 1
