Working with dates, times and timezones
Working with dates, times, and timezones can be hard.This guide aims to clarify how to work with these with PredictHQ data.
Event start and end local time
The Events API provides event start and end times in UTC and in the event local time format. The date and time fields available are:
The fields that provide local time are
start_local,end_local, andpredicted_end_local. These fields have the local time end date of the event in ISO 8601 format. This is the local time in the time zone at the event location. See the Events API Response Fields for more details on these fields.The fields
start,end, andpredicted_endhave date values in UTC format.
Date concepts
Internally, we have the concept of different date types for events. We don't expose these date types directly, but they surface indirectly and this guide demonstrates how to understand dates, times, and timezones on events. The different date types we refer to internally are:
Fixed Date
Fixed Time
Floating Date
Fixed Date
This concept refers to events that are known to happen on a certain date (including multi-day events) but the start and end times are not known. We represent these events in UTC, and they have a local start time of 00:00:00 and local end time of 23:59:59 as well as a known timezone, as in the following example:
The event in the earlier example is happening on Tue, 24 Oct 2023 (a single day) and using the convert_to_local function from the earlier Python code produces:
The start_local and end_local fields show the event spans the entire day of October 24th, 2023 in the Australia/Sydney timezone.
Fixed Time
Refers to events covering an exact time range. The start and end times are known (or predicted). We represent these events in UTC, and they have a timezone, as in this example:
Using the same convert_to_local function from earlier we get:
Showing the event is scheduled from 7:00 PM to 8:30 PM on November 9th, 2023 in the Australia/Melbourne timezone.
Floating Date
Refers to events that happen on a particular date regardless of timezone. E.g., USA Independence Day is 4th of July regardless of timezone. The way we represent this concept is by setting the timezone to null as in the following example:
When the timezone field is null like this you don't need to convert the start/end times.
Predicted End Times
Many events don't have scheduled end times, for many of these events we provide a predicted_end_time field (in UTC) and a predicted_end_local (in the time zone of the location of the event). When the start and end values are exactly the same, we know the start time but not the scheduled end time, so we provide a predicted_end value, as in this example:
Last updated
Was this helpful?