Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (TZ) => {
let winTz
let ianaTz
if (TZ !== 'UTC') {
winTz = ianaWin.findWindows(TZ)
ianaTz = ianaWin.findOneIana(TZ)
if (!winTz && !ianaTz) {
throw new Error(
`The timezone - ${TZ} - does not exist. Please provide a valid Windows or IANA time.`
)
}
}
if (os.platform() === 'win32') {
const previousTZ = execSync('tzutil /g').toString()
const cleanup = () => {
execSync(`tzutil /s "${previousTZ}"`)
console.log(`timezone was restored to ${previousTZ}`)
}
execSync(`tzutil /s "${winTz || TZ}"`)
module.exports = (TZ) => {
let winTz
let ianaTz
if (TZ !== 'UTC') {
winTz = ianaWin.findWindows(TZ)
ianaTz = ianaWin.findOneIana(TZ)
if (!winTz && !ianaTz) {
throw new Error(
`The timezone - ${TZ} - does not exist. Please provide a valid Windows or IANA time.`
)
}
}
if (os.platform() === 'win32') {
const previousTZ = execSync('tzutil /g').toString()
const cleanup = () => {
execSync(`tzutil /s "${previousTZ}"`)
console.log(`timezone was restored to ${previousTZ}`)
}
execSync(`tzutil /s "${winTz || TZ}"`)
console.warn(
client,
calendarId,
fetchStartDays,
fetchEndDays): Promise<*> {
const startDate = new Date();
const endDate = new Date();
startDate.setDate(startDate.getDate() + fetchStartDays);
endDate.setDate(endDate.getDate() + fetchEndDays);
const filter = `Start/DateTime ge '${
startDate.toISOString()}' and End/DateTime lt '${
endDate.toISOString()}'`;
const ianaTimeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
const windowsTimeZone = findWindows(ianaTimeZone);
return client
.api(`/me/calendars/${calendarId}/events`)
.filter(filter)
.header('Prefer', `outlook.timezone="${windowsTimeZone}"`)
.select('id,subject,start,end,location,body')
.orderby('createdDateTime DESC')
.get()
.then(result => result.value.map(item => {
return {
...item,
calendarId
};
}));
}