Per our discussion in the question chat, let's assume your input values are all Windows time zone identifiers.
The source of truth for conversion between Windows and IANA identifiers is the windowsZones.xml
file, part of the Unicode CLDR project.
You can parse the necessary data from this file using the xml features of Postgres, such as xmlparse
and xmltable
.
CREATE TABLE zone_mapping AS
SELECT xmltable.*
FROM XMLPARSE (DOCUMENT '...put xml here...')
AS data,
xmltable('//mapZone[@territory = ''001'']'
PASSING data
COLUMNS
windows_zone varchar PATH '@other' not null,
iana_zone varchar PATH '@type' not null
);
You can then query it, or join to it in your own queries, etc.
select * from zone_mapping;
Results will include the value you're looking for:
windows_zone iana_zone
-----------------------------------------------
...
Pacific Standard Time America/Los_Angeles
...
Working fiddle here (click Run at top).
Note that by filtering to the "001" territory (called the "Golden Zone"), the mapping table will work in the Windows to IANA direction only. If you need to go the other direction, then it's much more complex because not only do you have to take the other entries into consideration, but you also have to expand to all IANA aliases (links) using other data sources.
Also note when you paste your xml in, you'll need to replace any '
characters with ''
for the query. There is only one in the file presently.