Compiler-explorer: [BUG] zoneinfo files not available on godbolt.org?

Created on 24 Jul 2020  路  4Comments  路  Source: compiler-explorer/compiler-explorer

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

  • OS: Mac OS 10.15.6
  • Browser: Google Chrome
  • Version: 86.0.4210.0 (Official Build) canary (64-bit)

Additional context
zoneinfo files probably missing from the code sandbox.

bug

All 4 comments

/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. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daniel-j-h picture daniel-j-h  路  4Comments

mattgodbolt picture mattgodbolt  路  4Comments

LadaF picture LadaF  路  4Comments

Slabity picture Slabity  路  3Comments

rafaelreyesalvarez picture rafaelreyesalvarez  路  3Comments