Boost logo

Boost Users :

From: Brendon Costa (bcosta_at_[hidden])
Date: 2005-08-16 21:56:16


Hi,

    I have noticed that there seems to be a problem with the boost
date_time library 1.33 (Downloaded about 2 days ago) when trying to use
the localtime information under a NetBSD system. Specifically when I
have a small test program:

#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/c_local_time_adjustor.hpp"

#include <iostream>

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

   ptime loc = microsec_clock::local_time();
   ptime utc = microsec_clock::universal_time();
   std::cout << "Local: " << to_simple_string(loc) << std::endl;
   std::cout << "UTC: " << to_simple_string(utc) << std::endl;
  
   std::cout << "Local again: "
      << to_simple_string(
         boost::date_time::c_local_adjustor<ptime>::utc_to_local(utc))
      << std::endl;
   return 0;
}

It will display the same time for both UTC time and Local time (Living
in Melbourn Australia) where I expected them to differ. I found that the
above program would fail unless I did the following:

#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/c_local_time_adjustor.hpp"

#include <iostream>

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

   tzset();
   ptime loc = microsec_clock::local_time();
   ptime utc = microsec_clock::universal_time();
   std::cout << "Local: " << to_simple_string(loc) << std::endl;
   std::cout << "UTC: " << to_simple_string(utc) << std::endl;
  
   std::cout << "Local again: "
      << to_simple_string(
         boost::date_time::c_local_adjustor<ptime>::utc_to_local(utc))
      << std::endl;
   return 0;
}

Thanks,
Brendon Costa.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net