diff --git a/CHANGELOG.md b/CHANGELOG.md index 65eeb6e59f..a9ed20d18d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -746,6 +746,8 @@ 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. + ## [1.30.1] - 2018-12-10 ### Fixed diff --git a/scripts/test/dst.sh b/scripts/test/dst.sh index f4233ed7e2..5c756d2bf5 100755 --- a/scripts/test/dst.sh +++ b/scripts/test/dst.sh @@ -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 diff --git a/test/dst/eachDayOfInterval/basic.js b/test/dst/eachDayOfInterval/basic.js new file mode 100644 index 0000000000..8525a2beed --- /dev/null +++ b/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)' + ] +)