# SDK3 and timezone from calendar events

**URL:** <https://community.homey.app/t/sdk3-and-timezone-from-calendar-events/62772>\
**Category:** Developers\
**Tags:** app, tools, homey-pro\
**Created:** [April 17, 2022, 10:18am UTC](https://community.homey.app/t/sdk3-and-timezone-from-calendar-events/62772 "2022-04-17T10:18:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![runely](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/runely/32/28153_2.png) [@runely](https://community.homey.app/u/runely)\
**Post date:** [April 17, 2022, 10:18am UTC](https://community.homey.app/t/sdk3-and-timezone-from-calendar-events/62772/1 "2022-04-17T10:18:41Z")

</div>

As of SDK3, Athom has changed Homey to always work in UTC timezone… 🤦‍♂️

I am trying to move my app **IcalCalendar** from SDK2 to SDK3, but this change in timezone behavior has made it quite problematic.

In SDK2 the calendars were read and start / end were correctly converted to date objects with correct timezone offset.

In SDK3 the calendars are read but start / end are converted to date objects with UTC, and are missing timezone offsets.

I can use **moment** with the timezone found in Homey (_this.homey.clock.getTimezone()_) to get the offsets back, however i don’t seem to have found the correct way to add the offsets to the date to get correct start / end.

Has anyone has any luck achieving this correctly?

The code is here if someone would like to take a look: [calendar-homey/get-active-events.js at sdk3 · runely/calendar-homey · GitHub](https://github.com/runely/calendar-homey/blob/sdk3/lib/get-active-events.js#L74)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [April 17, 2022, 10:56am UTC](https://community.homey.app/t/sdk3-and-timezone-from-calendar-events/62772/2 "2022-04-17T10:56:50Z")

</div>

> [@runely](#):
>
> As of SDK3, Athom has changed Homey to always work in UTC timezone… 🤦‍♂️

Yes, just because Athom cannot handle timezones all developers have to suffer 😬

> [@](#):
>
> I can use **moment** with the timezone found in Homey ( _this.homey.clock.getTimezone()_ ) to get the offsets back, however i don’t seem to have found the correct way to add the offsets to the date to get correct start / end.

I’m not sure I understand.

You can use `moment-timezone` to convert a UTC timestamp to a local one:

```auto
const moment = require('moment-timezone');

const d1 = new Date();
console.log('Date', d1.toString(), 'Offset', d1.getTimezoneOffset());

const d2 = moment.tz(d1, 'Europe/Amsterdam');
console.log('Date', d2.toString(), 'Offset', d2.utcOffset());

```

If that’s not what you need, what exactly is it you do need? The code you’re linking to contains too much context to understand the underlying issue you’re having 😅

By the way, you can run the above code locally with Node.js, which saves some time with the whole make-a-minor-change-and-upload-your-entire-app cycle for Homey. To set the timezone to UTC, just like with SDKv3, you can use the `TZ` environment variable (at least on Linux and macOS):

```auto
$ env TZ=UTC node test.js

```

---

<div class="post-metadata">

**Author:** ![runely](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/runely/32/28153_2.png) [@runely](https://community.homey.app/u/runely)\
**Post date:** [April 18, 2022, 9:40pm UTC](https://community.homey.app/t/sdk3-and-timezone-from-calendar-events/62772/3 "2022-04-18T21:40:27Z")

</div>

I was already using `moment-timezone` to convert the date to local, but hadn’t found the correct way to add the offset. With your suggestion to set my local `TZ` to **UTC** it helped quite a lot and sped up the process, so thank you!
