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

Instant.add() does not cross the epoch correctly. #83

Open
kolton-musgrove opened this issue Jan 26, 2022 · 0 comments
Open

Instant.add() does not cross the epoch correctly. #83

kolton-musgrove opened this issue Jan 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@kolton-musgrove
Copy link
Collaborator

    describe('cross epoch in seconds', () => {
      const one = instantFns.subtract(inst, { hours: 240, seconds: 1 })
      const two = instantFns.add(inst, { hours: 240, seconds: 1 })
      const three = instantFns.subtract(two, { hours: 480, seconds: 1 })
      const four = instantFns.add(one, { hours: 480, seconds: 1 })

      it(`instantFns.subtract(${inst}), { hours: 240, seconds: 1 }) = ${one}`, () =>
        assert.equal(one, '1969-12-15T12:23:44.678Z'))
      it(`instantFns.add(${inst}, { hours: 240, seconds: 1 }) = ${two}`, () => assert.equal(two, '1970-01-04T12:23:46.678Z'))
      it(`instantFns.subtract(${two}, { hours: 480, seconds: 1 }) = ${one}`, () => assert(instantFns.equals(three, one)))
      it(`instantFns.add(${one}, { hours: 480, seconds: 1 }) = ${two}`, () => assert(instantFns.equals(four, two)))
    })

The preceding code generates timeshifts that are off by days, hours, minutes, and seconds when it should only change the day value be a single increment and the seconds by 1.

Output for the first asser.equal():

  • actual - expected

  • '1969-12-03T22:37:05.678Z'

  • '1969-12-15T12:23:44.678Z'
@kolton-musgrove kolton-musgrove added the bug Something isn't working label Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant