1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

test: remove api call for timezone

This commit is contained in:
Steven Tang 2023-01-21 19:39:28 +11:00
parent 0160a9ae52
commit 71563c2c33
No known key found for this signature in database
GPG Key ID: 1597520C734BAE66

View File

@ -3370,20 +3370,17 @@
"// pretend we're in Berlin, as this is also the time zone configured for the user",
"const userZone = 'Europe/Berlin'",
"",
"// postman doesn't have moment-timezone package included",
"// and we can't just use utcOffset(2), because of summer / winter time",
"// inspired by https://stackoverflow.com/a/56853085/3112139",
"function getUtcOffset(cb) {",
" let offset = pm.globals.get('utcOffset')",
" if (offset) return cb(offset)",
" pm.sendRequest(`https://worldtimeapi.org/api/timezone/${userZone}`, (err, res) => {",
" offset = res.json().utc_offset",
" pm.globals.set('utcOffset', offset)",
" return cb(offset)",
" })",
"// https://stackoverflow.com/a/63199512",
"// return UTC offset of timezone in minutes",
"function getTimezoneOffset(timeZone, date = new Date()) {",
" const tz = date.toLocaleString(\"en\", {timeZone, timeStyle: \"long\"}).split(\" \").slice(-1)[0];",
" const dateString = date.toString();",
" const offset = Date.parse(`${dateString} UTC`) - Date.parse(`${dateString} ${tz}`);",
" return offset / 1000 / 60;",
"}",
"",
"getUtcOffset((utcOffset) => {",
"const utcOffset = getTimezoneOffset(userZone);",
"",
"const now = moment().utcOffset(utcOffset)",
"const startOfDay = now.clone().startOf('day')",
"const endOfDay = now.clone().endOf('day')",
@ -3419,8 +3416,7 @@
"pm.variables.set('tsEndOfTomorrowIso', endOfTomorrow.toISOString())",
"pm.variables.set('ts1', now.clone().startOf('hour').format('x') / 1000)",
"pm.variables.set('ts2', now.clone().startOf('hour').add(1, 'm').format('x') / 1000)",
" pm.variables.set('ts3', now.clone().startOf('hour').add(2, 'm').format('x') / 1000)",
"})"
"pm.variables.set('ts3', now.clone().startOf('hour').add(2, 'm').format('x') / 1000)"
]
}
},