3

I have this program:

int main()
{
    using namespace boost::locale;

    generator gen;
    std::locale::global(gen(""));

    calendar cal("UTC");
    calendar cal_local("Europe/Berlin");

    date_time dt_utc(std::time(0), cal);
    date_time dt_local(std::time(0), cal_local);

    std::cerr << "UTC: " << dt_utc.get(period::hour()) << "\n";
    std::cerr << "LOCAL: " << dt_local.get(period::hour()) << "\n";
}

It behaves differently on two different but identical systems running Debian Wheezy with gcc 4.7.2-5 and boost 1.49. Both the systems have the same locale en_US.UTF-8.

The above program was executed at around Thu Sep 25 2014 11:15 UTC.

Output on System A

UTC: 11
LOCAL: 11

Output on System B

UTC: 11
LOCAL: 13

What should cause this?

Note: Currently DST is active for Europe/Berlin


Update:

libboost1.49-dev on both the systems is installed from a Debian repository as seen here:

user@system_a:~$ apt-cache policy libboost1.49-dev
libboost1.49-dev:
  Installed: 1.49.0-3.2
  Candidate: 1.49.0-3.2
  Version table:
 *** 1.49.0-3.2 0
        500 http://ftp2.de.debian.org/debian/ wheezy/main amd64 Packages
        100 /var/lib/dpkg/status

Also verified that libboost_locale.so has a dependencies libicuuc.so, libicui18n.so and libicudata.so on both the systems.

HAL
  • 3,888
  • 3
  • 19
  • 28
  • 1
    System A doesn't recognize `Europe/Berlin` timezone for some reason (and it defaults to UTC). Is the tz database available on that system? What happens if you intentionally misspell the timezone on System B? – jfs Sep 26 '14 at 11:33
  • @J.F.Sebastian tz database is available on system A(verified with `zdump /usr/share/zoneinfo/Europe/Berlin`). System B defaults to UTC with an intentionally misspelled timezone. – HAL Sep 26 '14 at 13:33
  • [the code](https://gist.github.com/zed/148e2cbd71be4de1bbd0) works on my machine (1.54 version). Have you tried to select the ICU backend explicitly? What `date_time now;` shows? – jfs Sep 26 '14 at 19:22
  • @J.F.Sebastian I tried your code with explicit ICU select but I still see the same result. What do you mean by `date_time now`? – HAL Sep 29 '14 at 07:44
  • I mean, check that the local time is what you expect. `date_time now;` gives you the current time. (Also check hardware clock is UTC or local (to dual boot with Windows). – jfs Sep 29 '14 at 07:46
  • @J.F.Sebastian `date_time now` displays time in `CEST`. And so does `hwclock(8)` – HAL Sep 29 '14 at 08:15

0 Answers0