Home > database >  Where in the ECMAScript spec for the Date() constructor does the time value get converted to epoch t
Where in the ECMAScript spec for the Date() constructor does the time value get converted to epoch t

Time:01-19

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:

  1. Find a finite time value t such that YearFromTime(t) is ym and MonthFromTime(t) is mn and DateFromTime(t) is 1
  •  Tags:  
  • Related