Skip to content

Commit

Permalink
Attempt to fix #972
Browse files Browse the repository at this point in the history
Remove code that causes #972. Most likely it will break something else,
but this is yet to figure.
  • Loading branch information
kossnocorp committed Dec 7, 2018
1 parent e2ff2ab commit 7150665
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
11 changes: 11 additions & 0 deletions scripts/test/regression.sh
@@ -0,0 +1,11 @@
#!/bin/bash

# The script runs the regression tests.
#
# It's a part of the test process.

set -ex

export PATH="$(yarn bin):$PATH"

env TZ=America/Sao_Paulo babel-node ./test/regression/972.js
3 changes: 0 additions & 3 deletions src/toDate/index.js
Expand Up @@ -188,9 +188,6 @@ export default function toDate(argument, dirtyOptions) {
} else {
// get offset accurate to hour in timezones that change offset
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time))
offset = getTimezoneOffsetInMilliseconds(
new Date(timestamp + time + offset)
)
}

return new Date(timestamp + time + offset)
Expand Down
14 changes: 14 additions & 0 deletions test/regression/972.js
@@ -0,0 +1,14 @@
// This is a regression test for issue #972: https://github.com/date-fns/date-fns/issues/972

import format from '../../src/format'
import assert from 'assert'

if (process.env.TZ !== 'America/Sao_Paulo')
throw new Error('The test must be run with TZ=America/Sao_Paulo')

const result = format('2018-11-04', 'yyyy-MM-dd HH:mm')
const expectation = '2018-11-04 01:00'
assert(
result === expectation,
`The result should be equal ${expectation} but got ${result}`
)

0 comments on commit 7150665

Please sign in to comment.