# Convert "dtStart"/"dtEnd" timezones of schedule to local timezone/timezone

**URL:** <https://discuss.dev.twitch.com/t/convert-dtstart-dtend-timezones-of-schedule-to-local-timezone-timezone/41915>\
**Category:** API\
**Created:** [November 15, 2022, 3:09pm UTC](https://discuss.dev.twitch.com/t/convert-dtstart-dtend-timezones-of-schedule-to-local-timezone-timezone/41915 "2022-11-15T15:09:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gewerd\_Strauss](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Gewerd\_Strauss](https://discuss.dev.twitch.com/u/Gewerd_Strauss)\
**Post date:** [November 15, 2022, 3:09pm UTC](https://discuss.dev.twitch.com/t/convert-dtstart-dtend-timezones-of-schedule-to-local-timezone-timezone/41915/1 "2022-11-15T15:09:25Z")

</div>

Hello,

I am retrieving the stream schedule of various channels via the API, using the `helix/schedule/icalendar`-endpoint. Each event then contains the `dtStart` and `dtEnd`-parameters, containing the start and end time.

However, against what I was expecting (and what various sources only assume as well), the timestamps retrieved by the API are _not in UTC_. E.g this is the return I receive for Critical Role:

```
BEGIN:VEVENT
UID:35fcc0f2-2d6f-4858-94c8-ca3cf6fbc2c5
DTSTAMP:20221114T234409Z
DTSTART;TZID=/America/New_York:20221117T190000
DTEND;TZID=/America/New_York:20221117T230000
SUMMARY:The Mighty Nein Reunited (Part 1)
DESCRIPTION:Dungeons & Dragons.
CATEGORIES:Dungeons & Dragons
END:VEVENT

```

Below is the (correctly) formatted time as displayed on the stream’s schedule when visiting the website. My timezone is UTC+1/UTC+2 (winter/summer).

 ![11_15_22 @3_35_32](https://d2opxh93rbxzdn.cloudfront.net/original/3X/9/e/9e5b92527588b097036a2eb5472cd632c6fc3bc6.png)  
For a channel in my own timezone, the values obviously match up, not that it’s relevant really.

The issue I am having is that I simply do not know how to convert from `Arbitrary TimezoneX` to `Arbitrary TimezoneY`, or to the local timezone (without hardcoding it in, I mean, which while possible is not _really_ a solution to this issue.)

And thus, I am kinda stuck.

Is this known behaviour, or should I have received UTC-formatted timestamps? Does anyone have any tips?

Thank you.  
Sincerely,  
~Gw

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 15, 2022, 3:19pm UTC](https://discuss.dev.twitch.com/t/convert-dtstart-dtend-timezones-of-schedule-to-local-timezone-timezone/41915/2 "2022-11-15T15:19:03Z")

</div>

> [@Gewerd\_Strauss](#):
>
> The issue I am having is that I simply do not know how to convert from `Arbitrary TimezoneX` to `Arbitrary TimezoneY`, or to the local timezone (without hardcoding it in, I mean, which while possible is not _really_ a solution to this issue.)

Use a time parsing library for your programming language of choice.  
Or since you are pulling the iCal feed, pass it into an iCal parsing library for your programming langauge of choice

Which is what any calendar system does (like google calendar) when you feed it the iCal URL.

so

> [@Gewerd\_Strauss](#):
>
> ```auto
> BEGIN:VEVENT
> UID:35fcc0f2-2d6f-4858-94c8-ca3cf6fbc2c5
> DTSTAMP:20221114T234409Z
> DTSTART;TZID=/America/New_York:20221117T190000
> DTEND;TZID=/America/New_York:20221117T230000
> SUMMARY:The Mighty Nein Reunited (Part 1)
> DESCRIPTION:Dungeons & Dragons.
> CATEGORIES:Dungeons & Dragons
> END:VEVENT
> 
> ```

DSTAMP is the time this iCal was generated. The `Z` specifies Zulu aka UTC

> [@Gewerd\_Strauss](#):
>
> ```auto
> DTSTART;TZID=/America/New_York:20221117T190000
> DTEND;TZID=/America/New_York:20221117T230000
> 
> ```

Start/endd  
Decalres the Timezone, New York, and it’s 2022 11 17 Time 19:00:00 thru 23:00:00 (New York Time)

This is according to the iCal speficiation. So no, not a unix timestamp.

---

<div class="post-metadata">

**Author:** ![Gewerd\_Strauss](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Gewerd\_Strauss](https://discuss.dev.twitch.com/u/Gewerd_Strauss)\
**Post date:** [November 15, 2022, 4:33pm UTC](https://discuss.dev.twitch.com/t/convert-dtstart-dtend-timezones-of-schedule-to-local-timezone-timezone/41915/3 "2022-11-15T16:33:18Z")

</div>

> pass it into an iCal parsing library for your programming langauge of choice
> 
> Which is what any calendar system does (like google calendar) when you feed it the iCal URL.

Which evidently does not appear to be the case for google cal - it converts these timestamps neither to UTC, nor to the timezone set in its own settings. Not sure _why_ - as there’s no reason for it not to, and plenty for it to do so, but that is evidently the case here, as shown above. ¯\_(ツ)\_/¯

I suppose I will search for a suitable lib then.

Thank you.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 15, 2022, 4:38pm UTC](https://discuss.dev.twitch.com/t/convert-dtstart-dtend-timezones-of-schedule-to-local-timezone-timezone/41915/4 "2022-11-15T16:38:55Z")

</div>

> [@Gewerd\_Strauss](#):
>
> Which evidently does not appear to be the case for google cal

Google seems to be showing various calendars _correctly_ with the right timezone offsets for when when added feeds to my Gcal.

So not sure what you mean here.

> [@Gewerd\_Strauss](#):
>
> Not sure _why_ - as there’s no reason for it not to, and plenty for it to do so, but that is evidently the case here, as shown above. ¯\_(ツ)\_/¯

I believe the iCal specification (from a quick scan) can’t do “normal” unix timestamps.

iCal runs off these formatted strings (TimeZone/LongForm date), which according to the spec is based on ISO 8601

See page 35 - [https://www.ietf.org/rfc/rfc2445.txt](https://www.ietf.org/rfc/rfc2445.txt)

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [December 15, 2022, 4:39pm UTC](https://discuss.dev.twitch.com/t/convert-dtstart-dtend-timezones-of-schedule-to-local-timezone-timezone/41915/5 "2022-12-15T16:39:27Z")

</div>

Closed on December 15, 2022, 4:39pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
