Describe the bug
I'd expect the following piece of code to display time formatted for 2 timezones when using cctz, but it doesn't.
#include <cctz/civil_time.h>
#include <cctz/time_zone.h>
#include <fmt/core.h>
#include <fmt/format.h>
void test_translating_civil_time() {
cctz::time_zone lax;
bool res = cctz::load_time_zone("America/Los_Angeles", &lax);
const auto tp = cctz::convert(cctz::civil_second(2015, 9, 22, 9, 0, 0), lax);
if (!res) {
fmt::print("tz n/a?\n");
}
cctz::time_zone nyc;
cctz::load_time_zone("America/New_York", &nyc);
fmt::print("{}\n", cctz::format("%T %z (%Z)", tp, lax));
fmt::print("{}\n", cctz::format("%T %z (%Z)", tp, nyc));
}
int main() {
test_translating_civil_time();
return 0;
}
It outputs:
tz n/a?
09:00:00 +0000 (UTC)
09:00:00 +0000 (UTC)
To Reproduce
Run the example in the compiler explorer link.
Expected behavior
I'd expect the above piece of code to display time formatted for 2 timezones when using cctz, but it doesn't. The following should be displayed instead:
09:00:00 -0700 (PDT)
12:00:00 -0400 (EDT)
Link
Here's a shortlink for the code snippet.
Desktop
Additional context
zoneinfo files probably missing from the code sandbox.
/usr/share/zoneinfo is likely the directory that needs to be added to our sandbox for this to work correctly.
May also need to whitelist /etc/localtime if we don't have it already.
Thanks @apmorton ; that seems like a pretty easy fix.
Fix is now live
That was fast! Love it! Thank you. :)