<div dir="ltr"><div dir="ltr">This all sounds good to me. I am guessing that we will not be able to get around a fairly large data set because of the need to keep the accuracy of the boundaries. There is a project called Timezone Boundary Builder (<a href="https://github.com/evansiroky/timezone-boundary-builder">https://github.com/evansiroky/timezone-boundary-builder</a>) that is a detailed polygon of the time zones based on OSM data with one attribute which is the time zone. When used in conjunction with the Time Zone Database (<a href="https://www.iana.org/time-zones">https://www.iana.org/time-zones</a>), it probably gives everything that is needed. QGIS already includes pytz which is the Time Zone Database.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 9, 2020 at 2:24 AM Richard Duivenvoorde <<a href="mailto:rdmailings@duif.net">rdmailings@duif.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 11/9/20 12:46 AM, Nyall Dawson wrote:<br>
> But more generally, I'd say you don't need any external library here.<br>
> Basically the library is just doing a point in polygon lookup against<br>
> the reference boundaries, and that's something which QGIS is already<br>
> awesome at ;) I'd suggest you just:<br>
> 1. find the format which gives smallest file size for the time zone boundaries<br>
> 2. include this in your plugin<br>
> 3. use native classes classes to read these boundaries and use<br>
> QgsFeatureRequest to do the point in polygon lookups.<br>
<br>
+1 !<br>
<br>
Thanks Nyall, for making this clear (to me).<br>
<br>
If we either create a new geopackage with timezones (geoms) in it and put it:<br>
<a href="https://github.com/qgis/QGIS/tree/master/resources/data" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS/tree/master/resources/data</a><br>
OR add it to current world_map.gpkg, you can use the 'inbuilt:' uri to get to the data<br>
(iface.addVectorLayer('inbuilt:/data/world_map.gpkg', 'Countries', 'ogr')) to (reverse) lookup timezones.<br>
<br>
Then use Qt's Datetime to handle the actual date/time-stuff.<br>
<br>
(What we do not tackle now is that QGIS itself does not handle this deep inside yet)<br>
<br>
Regards,<br>
<br>
Richard Duivenvoorde<br>
<br>
<br>
<br>
</blockquote></div></div>