Skip to content

Commit

Permalink
test north hemisphere spring too #233
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Oct 28, 2020
1 parent c9c8d72 commit 3b978ea
Showing 1 changed file with 42 additions and 16 deletions.
58 changes: 42 additions & 16 deletions test/dst-north.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
// })

0 comments on commit 3b978ea

Please sign in to comment.