Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setSeconds doesn't work correct with time conversion #7074

Closed
sruetzler opened this issue May 31, 2016 · 12 comments
Closed

setSeconds doesn't work correct with time conversion #7074

sruetzler opened this issue May 31, 2016 · 12 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@sruetzler
Copy link

  • Version: 4.4.5
  • Platform: Ubuntu 14.04.4 x63:64
  • Subsystem:

The problem still exists in 6.2.0

Tested in Timezone Europe/Berlin
Example Code:

date = new Date(1445734861000); //Sun Oct 25 2015 02:01:01 GMT+0100 (CET)
//Right after switching daylight saving off

date.setSeconds(0) //Sun Oct 25 2015 02:01:00 GMT+0200 (CEST)
date.getTime() //1445731260000

The date is now almost one hour before switching daylight saving off.
Expected date: Sun Oct 25 2015 02:01:00 GMT+0100 (CET)
At least in v0.10.32 this works.

@targos targos added the v8 engine Issues and PRs related to the V8 dependency. label May 31, 2016
@targos
Copy link
Member

targos commented May 31, 2016

@sruetzler
Copy link
Author

Yes I think this is the same problem.
The V8 issue priority is medium and it's open since Oct 2014.
For us this is a critical error is there a known workaround for this problem.

@jasnell
Copy link
Member

jasnell commented May 30, 2017

@targos ... is this still an issue?

@sruetzler
Copy link
Author

In node 6.10.3 this is still not working

@targos
Copy link
Member

targos commented May 30, 2017

Yes, this is still an issue, but we cannot fix it directly in Node

razvanz added a commit to razvanz/node-oauth2-server that referenced this issue Sep 25, 2017
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
razvanz added a commit to razvanz/node-oauth2-server that referenced this issue Sep 25, 2017
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
razvanz added a commit to razvanz/node-oauth2-server that referenced this issue Sep 25, 2017
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
razvanz added a commit to razvanz/node-oauth2-server that referenced this issue Sep 28, 2017
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
razvanz added a commit to razvanz/node-oauth2-server that referenced this issue Oct 27, 2017
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
@apapirovski
Copy link
Member

@nodejs/v8 Anyone know what could be done to resolve this issue? If anything? Seems like it's partially a spec problem but it's important to note that other browsers implement this differently.

@hashseed
Copy link
Member

The spec seems pretty clear on this one and hinges on LocalTZA. You could use Date.prototype.setUTCSeconds to work around this problem.

@apapirovski
Copy link
Member

Thanks @hashseed. Sounds like we should close on our end. There's an issue in V8 if anyone wants to track although it doesn't seem like it'll see much movement.

@bnoordhuis
Copy link
Member

The spec seems pretty clear on this one and hinges on LocalTZA.

Maybe I misunderstand but consider this:

> var d = new Date(1445734861000)

> d.getSeconds()
1

> d.getTimezoneOffset()
-60

> d.setSeconds(0)
1445731260000

# or:
> d.getTime() - d.setSeconds(0)
3601000

> d.getTimezoneOffset()
-120  # bad

V8 computes the local time offset once in PosixDefaultTimezoneCache::LocalTimeOffset() and caches it. Is the timezone jump a DST thing then? Because setting e.g. TZ=UTC-1 (no DST) fixes it.

@apapirovski
Copy link
Member

I'm just skimming this but I think this is related to LocalTime in the spec:

When tlocal represents local time repeating multiple times at a negative time zone transition (e.g. when the daylight saving time ends or the time zone adjustment is decreased due to a time zone rule change) or skipped local time at a positive time zone transitions (e.g. when the daylight saving time starts or the time zone adjustment is increased due to a time zone rule change), tlocal must be interpreted with the time zone adjustment before the transition.

(link above per @hashseed)

@bnoordhuis
Copy link
Member

Yep, I saw the note that "UTC(LocalTime(t)) is not necessarily always equal to t" and that's no understatement because d.setSeconds(d.getSeconds()) exhibits the same timezone jump.

I wouldn't call it intuitive but I guess it is conforming.

@hashseed
Copy link
Member

hashseed commented Apr 12, 2018

Yes. There is a DST jump at precisely that time.

What setSeconds does is that it converts the time into UTC based on the time offset at that time. After it has calculated the new time, it converts the time back to local time based on the time offset at the new time.

The time offsets differ by an hour according to ICU.

mjsalinger pushed a commit to mjsalinger/node-oauth2-server that referenced this issue Aug 27, 2018
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
thomseddon pushed a commit to oauthjs/node-oauth2-server that referenced this issue Jun 11, 2020
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
thomseddon pushed a commit to oauthjs/node-oauth2-server that referenced this issue Jun 11, 2020
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
thomseddon pushed a commit to oauthjs/node-oauth2-server that referenced this issue Jun 27, 2020
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
thomseddon pushed a commit to oauthjs/node-oauth2-server that referenced this issue Jun 27, 2020
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
thomseddon pushed a commit to oauthjs/node-oauth2-server that referenced this issue Jun 30, 2020
related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.
sambacha pushed a commit to sambacha/node-oauth2-server that referenced this issue Sep 27, 2020
* Compute the correct redirect_uri in case of resource over denies access

According to https://tools.ietf.org/html/rfc6749#section-4.1.2.1
once the redirect_uri & client_id is correct authorization server should
inform the clinet, that user denied access.

The change is to move validation of resource owner approval after the
redirect_uri & client identifier validation so the correct redirect url
is computed

* Remove commented code

* Note we're now also seeking reviewers

* Update readme with link to v5-dev branch

* Add renovate.json

* Add link to examples repo. Closes oauthjs#571

* Update dependency bluebird to v3.7.2

* Update dependency jshint to v2.11.0

* Update dependency mocha to v3.5.3

* Update dependency sinon to v2.4.1

* Update dependency statuses to v1.5.0

* Update dependency basic-auth to v2

* Update node versions

* Bump lodash from 4.17.4 to 4.17.15

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.4 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.4...4.17.15)

Signed-off-by: dependabot[bot] <[email protected]>

* Update dependency type-is to v1.6.18

* Update dependency should to v13

* add codecoverage and upgrade packages

* Update dependency jshint to v2.11.1

* Drop support for node 4/6/8 and add tests for 14

* Update dependency sinon to v9

* Update dependency mocha to v7

* Release 3.0.2 🎉

* Release 3.0.2 🎉

* Revert "Drop support for node 4/6/8 and add tests for 14"

This reverts commit b84778b.

* Revert "Merge pull request oauthjs#596 from oauthjs/renovate/mocha-7.x"

This reverts commit cb2bb88, reversing
changes made to 6997303.

* Revert "Merge pull request oauthjs#602 from oauthjs/renovate/sinon-9.x"

This reverts commit 6997303, reversing
changes made to b84778b.

* Bump mocha and sinon to lastest versions supporting node v4

* Add testing for node v14

* Update readme with project status update

* remove renovate in favour of dependabot

* Add FUNDING.yml (oauthjs#630)

* Updated .gitignore

* Changed 'hasOwnProperty' call in Request

* Changed 'hasOwnProperty' call in Response

* set numArgs for promisify of generateAuthorizationCode

* readme: Update Slack badge and link

* fix: issue correct expiry dates for tokens oauthjs#444

related to a NodeJS (nodejs/node#7074) and furthermore
V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced
seconds calculation with milliseconds.

* Merge pull request oauthjs#451 from razvanz/fix/validate-scope-on-authorize

 fix: validate requested scope on authorize request

* Merge pull request oauthjs#491 from mattgrande/master

docs: Ensure accessTokenExpiresAt is required

* Merge pull request oauthjs#471 from smartrecruiters/fix-migration-documentaiton

docs: Correct tokens time scale for 2.x to 3.x  migration guide

* Updated changelog

* Tag 3.1.0-rc1

* 3.1.0 bump

* Bump lodash from 4.17.15 to 4.17.19

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.15...4.17.19)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* v3.1.1 (oauthjs#636)

* Bump jshint from 2.11.1 to 2.12.0 (oauthjs#640)

Bumps [jshint](https://github.com/jshint/jshint) from 2.11.1 to 2.12.0.
- [Release notes](https://github.com/jshint/jshint/releases)
- [Changelog](https://github.com/jshint/jshint/blob/master/CHANGELOG.md)
- [Commits](jshint/jshint@2.11.1...2.12.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Set WWW-Authenticate header for invalid requests

This adds the WWW-Authenticate header for InvalidRequestError, InvalidTokenError,
and InsufficientScopeError, as specified in RFC 6750, Section 3

Fixes oauthjs#553

* cherry pick

* rm lock

* fix: lint erros

* fix grant types

* custom types init

* Update .travis.yml

* git merge artifact

Co-authored-by: Igor Czechowski <[email protected]>
Co-authored-by: Szymon Kiebzak <[email protected]>
Co-authored-by: Thom Seddon <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aras Abbasi <[email protected]>
Co-authored-by: mjsalinger <[email protected]>
Co-authored-by: Pritilender <[email protected]>
Co-authored-by: nkzawa <[email protected]>
Co-authored-by: Max Truxa <[email protected]>
Co-authored-by: Razvan <[email protected]>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Jonas Hermsmeier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

6 participants