id summary reporter owner description type status milestone component version severity resolution keywords cc 9584 date_time::difference produces incorrect values Alexey Spiridonov Artyom Beilis "The program below attempts to compute the local timezone's GMT offset for a given timestamp. The idea is simple. First, get the year-month-day-hour-minute-second representation of the timestamp in the local timezone. Then, create a UTC date_time with exactly the same components. The difference between those times is exactly the UTC offset. The program gives this: {{{ g++ -std=c++11 c.cpp -o c -l boost_locale ; ./c 1383469199 ; ./c 0; -25199 -28799 }}} The expected output is 28800 (8 hours) both times, since my computer's local timezone is America/Los_Angeles (or Pacific Time). {{{#!c++ #include #include int compute_utc_offset_seconds(time_t time_since_utc_epoch) { using namespace boost::locale; std::locale loc = generator()(""""); // Get the local time coordinates for the given timestamp date_time local_dt{(double)time_since_utc_epoch, calendar(loc)}; // Copy the date_time coordinates into a UTC value date_time utc_dt{calendar(loc, ""UTC"")}; for (auto p : { period::year(), period::month(), period::day(), period::hour(), period::minute(), period::second() }) { utc_dt.set(p, local_dt.get(p)); } return local_dt.difference(utc_dt, period::second()); } int main(int argc, char **argv) { if (argc < 2) { return 1; } std::cout << compute_utc_offset_seconds(atoi(argv[1])) << std::endl; return 0; } }}} " Bugs closed To Be Determined locale Boost 1.54.0 Problem fixed