Accounting for leap seconds for "this time value"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Accounting for leap seconds for "this time value"

Qantas 94 Heavy
The current specification has this to say about the time value in dates:

"Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. In time values leap seconds are ignored. It is assumed that there are exactly 86,400,000 milliseconds per day."

What I would like to seek clarification about is if we were to do the following:

```js
Math.floor(Date.now() / 1000) % 60;
```

Would complying with the specification mean that this value calculated for the "seconds" should not correspond with the time shown outside of JavaScript (because of leap seconds)?  For example, if that code returns "30", would that mean that a clock following UTC should show a seconds value of "04"? At the moment, it seems that the implementations I have tested do not follow this.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Accounting for leap seconds for "this time value"

Claude Pache

That means that `Date.now()/1000` is the [Unix time] (https://en.wikipedia.org/wiki/Unix_time), which can't represent leap seconds. In particular, each minute is assumed to have exactly 60 seconds, and thus it is impossible to represent `1981-06-30 23:59:60 UTC` in JS (or in Unix time). 

—Claude


Le 3 sept. 2015 à 11:40, Karl Cheng <[hidden email]> a écrit :

The current specification has this to say about the time value in dates:

"Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. In time values leap seconds are ignored. It is assumed that there are exactly 86,400,000 milliseconds per day."

What I would like to seek clarification about is if we were to do the following:

```js
Math.floor(Date.now() / 1000) % 60;
```

Would complying with the specification mean that this value calculated for the "seconds" should not correspond with the time shown outside of JavaScript (because of leap seconds)?  For example, if that code returns "30", would that mean that a clock following UTC should show a seconds value of "04"? At the moment, it seems that the implementations I have tested do not follow this.
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Accounting for leap seconds for "this time value"

Michael McGlothlin-2
Wouldn't the leap seconds be only formatting for display where as time stored in epochs is universal? If I'm on Mars the epochs value is the same whereas local time (on Mars) may have a totally different set of adjustments to keep the human readable time true to that planets rotation etc.


📱 Michael McGlothlin

On Sep 3, 2015, at 5:06 AM, Claude Pache <[hidden email]> wrote:


That means that `Date.now()/1000` is the [Unix time] (https://en.wikipedia.org/wiki/Unix_time), which can't represent leap seconds. In particular, each minute is assumed to have exactly 60 seconds, and thus it is impossible to represent `1981-06-30 23:59:60 UTC` in JS (or in Unix time). 

—Claude


Le 3 sept. 2015 à 11:40, Karl Cheng <[hidden email]> a écrit :

The current specification has this to say about the time value in dates:

"Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. In time values leap seconds are ignored. It is assumed that there are exactly 86,400,000 milliseconds per day."

What I would like to seek clarification about is if we were to do the following:

```js
Math.floor(Date.now() / 1000) % 60;
```

Would complying with the specification mean that this value calculated for the "seconds" should not correspond with the time shown outside of JavaScript (because of leap seconds)?  For example, if that code returns "30", would that mean that a clock following UTC should show a seconds value of "04"? At the moment, it seems that the implementations I have tested do not follow this.
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss