Skip to content

Commit

Permalink
Fix DST issue in eachDayOfInterval
Browse files Browse the repository at this point in the history
Fix DST issue in `eachDayOfInterval` that caused time in the days
after DST change to have the shift as well.
  • Loading branch information
kossnocorp committed Jan 9, 2019
1 parent 37bb142 commit 838ed9f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -748,6 +748,9 @@ for the list of changes made since `v2.0.0-alpha.1`.

- [Fixed DST issue](https://github.com/date-fns/date-fns/pull/1003). See [#972](https://github.com/date-fns/date-fns/issues/972) and [#992](https://github.com/date-fns/date-fns/issues/992) for more details.

- Fixed DST issue in `eachDayOfInterval` that caused time in the days
after DST change to have the shift as well.

- Fix bug in Galician locale caused by incorrect usage of `getHours`
instead of `getUTCHours`.

Expand Down
1 change: 1 addition & 0 deletions scripts/test/dst.sh
Expand Up @@ -10,3 +10,4 @@ export PATH="$(yarn bin):$PATH"

env TZ=America/Sao_Paulo babel-node ./test/dst/parseISO/basic.js
env TZ=Pacific/Apia babel-node ./test/dst/parseISO/samoa.js
env TZ=Asia/Damascus babel-node ./test/dst/eachDayOfInterval/basic.js
22 changes: 22 additions & 0 deletions test/dst/eachDayOfInterval/basic.js
@@ -0,0 +1,22 @@
// This is basic DST test for eachDayOfInterval

import eachDayOfInterval from '../../../src/eachDayOfInterval'
import assert from 'assert'

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

if (parseInt(process.version.match(/^v(\d+)\./)[1]) < 10)
throw new Error('The test must be run on Node.js version >= 10')

assert.deepEqual(
eachDayOfInterval({
start: new Date(2020, 2, 26),
end: new Date(2020, 2, 28)
}).map(d => d.toString()),
[
'Thu Mar 26 2020 00:00:00 GMT+0200 (Eastern European Standard Time)',
'Fri Mar 27 2020 01:00:00 GMT+0300 (Eastern European Summer Time)',
'Sat Mar 28 2020 00:00:00 GMT+0300 (Eastern European Summer Time)'
]
)

0 comments on commit 838ed9f

Please sign in to comment.