Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
Where in the ECMAScript spec for the Date() constructor does the time value get converted to epoch time?

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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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𝔽;

This is a rather obscure definition, using the operations defined in 21.4.1.3 "Year Number". There we can find the formula

DayFromYear(y) = 𝔽(365 × (ℝ(y) - 1970) + floor((ℝ(y) - 1969) / 4) - floor((ℝ(y) - 1901) / 100) + floor((ℝ(y) - 1601) / 400))

This comes out to have "day 0" as the first day of 1970.

But rather than deriving that from this formula, we can just read 21.4.1.1 "Time Values and Time Range":

The exact moment of midnight at the beginning of 1 January 1970 UTC is represented by the time value +0𝔽.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda