From 3b978ea15147e24d93fc12b7325d0dea76aeebc5 Mon Sep 17 00:00:00 2001 From: spencer kelly Date: Wed, 28 Oct 2020 18:43:24 -0400 Subject: [PATCH] test north hemisphere spring too #233 --- test/dst-north.test.js | 58 ++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/test/dst-north.test.js b/test/dst-north.test.js index 34c6c5fc..1637a627 100644 --- a/test/dst-north.test.js +++ b/test/dst-north.test.js @@ -15,41 +15,67 @@ let zones = [ 'america/indianapolis', 'america/tijuana', //11/01:02 -7hrs 'mexico/bajanorte', //11/01:02 -7hrs - 'america/havana', + // 'america/havana', 'america/indiana', 'america/kentucky', - 'america/north_dakota', - 'america/scoresbysund', - 'asia/amman', - 'asia/gaza', - 'asia/hebron', - 'atlantic/azores', - 'asia/damascus', //10/29:24 - 'asia/beirut', //10/24:24 - 'asia/tehran' //09/20:24 + 'america/north_dakota' + // 'america/scoresbysund', + // 'asia/amman', + // 'asia/gaza', + // 'asia/hebron', + // 'atlantic/azores', + // 'asia/damascus', //10/29:24 + // 'asia/beirut', //10/24:24 + // 'asia/tehran' //09/20:24 ] -test('increment-to-fall-back', (t) => { +test('north-increment-spring', (t) => { zones.forEach((tz) => { // get fall dst change let dstStr = spacetime().timezones[tz].dst - let change = dstParse(dstStr, 1) + let change = dstParse(dstStr, 0) //create a date 2mins after dst change - let after = spacetime(change, tz) + let before = spacetime(change, tz).minus(1, 'hour') // create a time 2hrs before a dst change (-3hrs) - let before = after.clone().minus(3, 'hours') + let after = before.clone().add(2, 'hours') + // console.log(before.format('nice'), after.format('nice')) // start rolling towards the dst shift (but don't hit it) for (let i = 0; i < 12; i += 1) { let time = before.time() t.equal(before.isBefore(after), true, time + ' before-change ' + tz) - t.equal(before.timezone().current.isDST, true, time + ' dst-on ' + tz) + t.equal(before.timezone().current.isDST, false, time + ' dst-off ' + tz) before = before.add(10, 'minutes') } for (let i = 0; i < 14; i += 1) { let time = before.time() - t.equal(before.timezone().current.isDST, false, time + ' dst-now-off ' + tz) + t.equal(before.timezone().current.isDST, true, time + ' dst-now-on ' + tz) before = before.add(10, 'minutes') } }) t.end() }) + +// test('north-increment-fall', (t) => { +// zones.forEach((tz) => { +// // get fall dst change +// let dstStr = spacetime().timezones[tz].dst +// let change = dstParse(dstStr, 1) +// //create a date 2mins after dst change +// let after = spacetime(change, tz) +// // create a time 2hrs before a dst change (-3hrs) +// let before = after.clone().minus(3, 'hours') +// // start rolling towards the dst shift (but don't hit it) +// for (let i = 0; i < 12; i += 1) { +// let time = before.time() +// t.equal(before.isBefore(after), true, time + ' before-change ' + tz) +// t.equal(before.timezone().current.isDST, true, time + ' dst-on ' + tz) +// before = before.add(10, 'minutes') +// } +// for (let i = 0; i < 14; i += 1) { +// let time = before.time() +// t.equal(before.timezone().current.isDST, false, time + ' dst-now-off ' + tz) +// before = before.add(10, 'minutes') +// } +// }) +// t.end() +// })