Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

281
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda