Where to download date::locate_zone database?
Added by Saif Rehman over 6 years ago
Hi,
I am using the line "newLocale.setTimeZone(date::locate_zone(tr("TimeZone").toUTF8()));" to set the WLocale time zone. Now I'm not sure how date::locate_zone works but on Windows it is giving me an error that the file my in user download's folder "D:\Downloads\tzdata" is not found.
Since the date namespace is not documented, can you please tell me how to enable AUTO_DOWNLOAD or where to download this timezone database file and how to load this file from approot instead of the default location?
Replies (2)
RE: Where to download date::locate_zone database? - Added by Saif Rehman over 6 years ago
I downloaded the database from https://www.iana.org/time-zones but it doesn't contain windowsZones.xml and I'm getting the error 'Error opening time zone mapping file "D:\Downloads\tzdata\windowsZones.xml"'
RE: Where to download date::locate_zone database? - Added by Roel Standaert over 6 years ago
That's indeed something that's still a bit problematic about our usage of Howard Hinnant's time_zone implementation. I'm still not sure what to do with those compilation parameters, some of which change the ABI. I would like it to be possible to use it as an external library rather than embedded into Wt (and eventually make it possible to use the standard implementation from C++20), but that still seems a bit finicky. I made an attempt earlier when I was updating its version to 2.4.1, but I couldn't quite get it to work properly. It's possible that his CMakeLists.txt
needs some more tweaking. It seems to me, but I could be wrong, that only date_interface is exported, and not the tz library.
At the moment we compile with:
- INSTALL set to its default (which is indeed tzdata in the user's Downloads folder)
- HAS_REMOTE_API disabled
- AUTO_DOWNLOAD disabled
- USE_OS_TZDB disabled on Windows, enabled on Unix/Linux
This means that it mostly just works on Linux, but some extra setup is required on Windows.
Using date::set_install
you can change where it looks for the time zone information.
The locale example in examples/feature/locale
provides some more info on how to get the time zone information:
- Create a
tzdata
directory (in your Downloads folder or some other folder that you configure withdate::set_install
) - Download the latest time zone database from IANA: https://www.iana.org/time-zones (Choose the Data Only Distribution), and extract its contents into the
tzdata
directory you just created. - Download
windowsZones.xml
from https://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml and add it to thetzdata
directory.